[hibernate-dev] Thread-Safety of NoopOptimizer

Sanne Grinovero sanne at hibernate.org
Tue Jul 1 13:54:50 EDT 2014


I'm trying to understand if the NoopOptimizer could drop the
"synchronized" at line 53.

I added the synchronization myself some months ago, when we discovered
that we could remove a level of synchronization which was more coarse
grained, but then when inspecting the safety of the various smaller
parts, when hitting the NoopOptimizer I wasn't too sure - as the
AccessCallback is pluggable - and opted to be safe rather than sorry
as I thought this Optimizer would not be used in a high-performance
use case.

It seems I was wrong an some people actually use this Optimizer in a
scenario needing high scalability, and this one also happens to be the
default Optimizer.

By looking at all AccessCallback implementors in the ORM codebase, it
looks like safe to remove the synchronization, but are there reliable
tests I could use to verify this?

There are some more optimisations that come to mind when looking into
the various Optimizer and Generator implementors, but I don't feel
comfortable into changing these without running some stress tests.

TiA,
Sanne


More information about the hibernate-dev mailing list