On Sat, 6 Mar 2021 12:36:02 GMT, David Holmes <dhol...@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

Reply via email to