Open shipilev opened 4 years ago
Interesting, I'd never have thought of that, I guess I'm too used to optimize code for tracing JITs (LuaJIT in particular).
Changing the field to static indeed boosts performance by 3% when applied on top of https://github.com/ixy-languages/ixy.java/issues/6
Thanks! I'd love to update the performance graphs, but we'll figure out why it doesn't work on the reference system with the 3.3 GHz CPU used by all the other tests first :/
Right. I would probably apply this much simpler fix first -- if there are consecutive Unsafe
acceses, just static final
-ing the Unsafe
holder field might give a significant boost, even without fixing #6. That is, it might be even more than 3% that way around.
This is better captured by the microbenchmark. Unsafe performance relies heavily on the JIT compiler being able to nuke down everything to the raw memory accesses.
Part of that story is null-checking the
Unsafe
instance itself. When compiler is not sure about it (and it does not right now, as the field is justfinal
right now inUnsafeMemoryManager
), it would emit null-checks and then barrier coalescing would break.Copy-pasting the results from the microbenchmark test above:
This seems to be easy to do:
(Unfortunately, I don't have the hardware to test it... yet).