Hibernate Classloader Synced Calls

We have a performance issue in our project that appears to arise (at least in part) from the way Hibernate uses the class loader. This was discovered in dumps of Java threads that were accepted during high-load tests in our internal environment. The reset JVM is the Weblogic managed server JVM that runs the application, and dumps have been made while the dashboard shows the hang threads and pending user requests.

Example:

"[ACTIVE] ExecuteThread: '126' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00007f2fe9486000 nid=0x663b waiting for monitor entry [0x00007f2faeae6000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:405)
    - waiting to lock <0x000000078c0d76b0> (a weblogic.utils.classloaders.GenericClassLoader)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:178)
    at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:187)
    at org.hibernate.internal.util.ReflectHelper.getConstantValue(ReflectHelper.java:278)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl$JavaConstantConverter.handleDotStructure(QueryTranslatorImpl.java:592)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl$JavaConstantConverter.visit(QueryTranslatorImpl.java:587)

, ( Samurai/TDA), , , . , WLS, , / ...

, Hibernate . , classloader .

, , , ... 30% (~ 30-40 + 130) .

- > , WLS , (.. Hibernate).

- ?

, -, , , . , , CPU/ WLS- (, EJB/JDBC-/...) - JVM, .

.


P.S.

Google , , (, Oracle), / .

+4
3

, , Class.forName() Classloader.loadClass() new Object(). , .

JPQL http://dimovelev.blogspot.dk/2015/02/performance-pitfalls-hibernate-criteria.html

+3

Hibernate Jira:

Class.forName . , . Pierre-Hugues Charbonneau , .

, HHH-4959 Jira ​​ Hibernate 5.2.6, .

+2

jdk1.6 java.lang.ClassLoader loadClass syncs,

protected synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException

jdk1.7 makes every lock for className, which is more efficient

protected Class<?> loadClass(String name, boolean resolve)throws ClassNotFoundException{
   synchronized (getClassLoadingLock(name)) 
0
source

All Articles