<i18n dev> RFR: 8263090: Avoid reading volatile fields twice in Locale.getDefault(Category) [v2]

Claes Redestad redestad at openjdk.java.net
Sat Mar 6 13:13:04 UTC 2021

On Sat, 6 Mar 2021 12:36:02 GMT, David Holmes <dholmes at openjdk.org> wrote:

> If I read the order right your benchmark findings were done before you added the missing synchronized - correct?
> AFAICS the only unnecessary volatile read is on the return statement and you could fix that without doing the other refactoring. I don't see how introducing an extra method call can aid performance.

Note that the score for the Display and the Format case were identical, even though one was missing synchronized. I've re-run the benchmarks after the fix and the same applies.

The methods will only ever be called during initialization, usually only once. Extracting them to separate methods helps outline initialization code from the hot path. Such outlining is a standard technique to help the JITs do the right thing, for example by ensuring you don't stumble on things like inlining thresholds.


PR: https://git.openjdk.java.net/jdk/pull/2845

More information about the i18n-dev mailing list