|
When having an ORM intensive application which uses Validator too, the amount of parallel worker threads can get pretty high. On my 12 core machine, a good sweet spot is around approximately 100 threads working to satisfy requests in parallel: as each transaction involves several roundtrips to the database there is quite some opportunity to context switch. Now with so many parallel threads, we're looking at two different causes which prevent the application from going faster: 1) how quick a single transaction can work (of efficient it can be) 2) how good these many different threads are able to not interfere with each other (contention points).
This is one such contention point, and in my specific test which is quite Hibernate focused, it's the highest contention point of the application server, followed only by the datasource connection pool.
My initial approch for caching the result of isGroupSequence in a concurrent map didn't work, I only later figured out that the whole ValidatorImpl is created on each call, I didn't expect that.. essentially my cache was empty on each invocation again 
Now considering the invocation of Class.initAnnotationsIfNecessary() is probably extremely cheap when there is no contention, I'm going to propose a patch which primarily aims at making the invocations on this method less frequent, that should avoid the threads from ever crossing each other again on this path... I'm testing it again.
|