From: Sergey V. (JIRA) <no...@at...> - 2006-02-16 01:36:16
|
QueryCache should not call EntityType.getReturnedClass() or do it fast ---------------------------------------------------------------------- Key: HHH-1490 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490 Project: Hibernate3 Type: Improvement Components: core Versions: 3.1.2 Environment: Hibernate 3.1.2, MySQL 5.0.18-nt Reporter: Sergey Vladimirov Priority: Minor org.hibernate.cache.QueryKey should not call EntityType.getReturnedClass() or do it fast, because EntityType.getReturnedClass() works with ClassLoader - i is very expensive operation: Stack trace: java.lang.ClassLoader.findLoadedClass0(Native Method) java.lang.ClassLoader.findLoadedClass(ClassLoader.java:922) java.lang.ClassLoader.loadClass(ClassLoader.java:295) - locked sun.misc.Launcher$AppClassLoader@93dee9 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) - locked sun.misc.Launcher$AppClassLoader@93dee9 java.lang.ClassLoader.loadClass(ClassLoader.java:251) org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:95) org.hibernate.type.EntityType.getReturnedClass(EntityType.java:91) org.hibernate.cache.QueryKey.equals(QueryKey.java:59) org.apache.commons.collections.map.AbstractReferenceMap.isEqualKey(AbstractReferenceMap.java:433) org.apache.commons.collections.map.AbstractHashedMap.getEntry(AbstractHashedMap.java:434) org.apache.commons.collections.map.AbstractReferenceMap.getEntry(AbstractReferenceMap.java:404) org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:229) ru.arptek.common.collections.SynchronizedMap.get(SynchronizedMap.java:94) Operations with ClassLoaders is not falst enought for equals() operations. May be one should add some kind of caching (in EntityType, for example) or compare EntityType by class names, not by Class objects. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Sergey V. (JIRA) <no...@at...> - 2006-06-30 09:01:29
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490?page=all ] Sergey Vladimirov updated HHH-1490: ----------------------------------- Attachment: patch.txt Patch to cache classes > QueryCache should not call EntityType.getReturnedClass() or do it fast > ---------------------------------------------------------------------- > > Key: HHH-1490 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490 > Project: Hibernate3 > Type: Improvement > Components: core > Versions: 3.1.2 > Environment: Hibernate 3.1.2, MySQL 5.0.18-nt > Reporter: Sergey Vladimirov > Priority: Minor > Attachments: patch.txt > > > org.hibernate.cache.QueryKey should not call EntityType.getReturnedClass() or do it fast, because EntityType.getReturnedClass() works with ClassLoader - i is very expensive operation: > Stack trace: > java.lang.ClassLoader.findLoadedClass0(Native Method) > java.lang.ClassLoader.findLoadedClass(ClassLoader.java:922) > java.lang.ClassLoader.loadClass(ClassLoader.java:295) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > java.lang.ClassLoader.loadClass(ClassLoader.java:251) > org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:95) > org.hibernate.type.EntityType.getReturnedClass(EntityType.java:91) > org.hibernate.cache.QueryKey.equals(QueryKey.java:59) > org.apache.commons.collections.map.AbstractReferenceMap.isEqualKey(AbstractReferenceMap.java:433) > org.apache.commons.collections.map.AbstractHashedMap.getEntry(AbstractHashedMap.java:434) > org.apache.commons.collections.map.AbstractReferenceMap.getEntry(AbstractReferenceMap.java:404) > org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:229) > ru.arptek.common.collections.SynchronizedMap.get(SynchronizedMap.java:94) > Operations with ClassLoaders is not falst enought for equals() operations. May be one should add some kind of caching (in EntityType, for example) or compare EntityType by class names, not by Class objects. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-06-30 15:53:29
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490?page=comments#action_23505 ] Emmanuel Bernard commented on HHH-1490: --------------------------------------- Why is it expensive? The method call is basically hitting the classloader cache which is kind of a native hash map > QueryCache should not call EntityType.getReturnedClass() or do it fast > ---------------------------------------------------------------------- > > Key: HHH-1490 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490 > Project: Hibernate3 > Type: Improvement > Components: core > Versions: 3.1.2 > Environment: Hibernate 3.1.2, MySQL 5.0.18-nt > Reporter: Sergey Vladimirov > Priority: Minor > Attachments: patch.txt > > > org.hibernate.cache.QueryKey should not call EntityType.getReturnedClass() or do it fast, because EntityType.getReturnedClass() works with ClassLoader - i is very expensive operation: > Stack trace: > java.lang.ClassLoader.findLoadedClass0(Native Method) > java.lang.ClassLoader.findLoadedClass(ClassLoader.java:922) > java.lang.ClassLoader.loadClass(ClassLoader.java:295) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > java.lang.ClassLoader.loadClass(ClassLoader.java:251) > org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:95) > org.hibernate.type.EntityType.getReturnedClass(EntityType.java:91) > org.hibernate.cache.QueryKey.equals(QueryKey.java:59) > org.apache.commons.collections.map.AbstractReferenceMap.isEqualKey(AbstractReferenceMap.java:433) > org.apache.commons.collections.map.AbstractHashedMap.getEntry(AbstractHashedMap.java:434) > org.apache.commons.collections.map.AbstractReferenceMap.getEntry(AbstractReferenceMap.java:404) > org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:229) > ru.arptek.common.collections.SynchronizedMap.get(SynchronizedMap.java:94) > Operations with ClassLoaders is not falst enought for equals() operations. May be one should add some kind of caching (in EntityType, for example) or compare EntityType by class names, not by Class objects. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Sergey V. (JIRA) <no...@at...> - 2006-06-30 20:24:16
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490?page=comments#action_23510 ] Sergey Vladimirov commented on HHH-1490: ---------------------------------------- I don't know why is it expecive. May be need a good test case... But all my perfomance requests are from real application. I just making 3-5 stack traces and look, what methods are stuck. For example, I often see org.hibernate.type.EntityType.getReturnedClass(EntityType.java:91) org.hibernate.cache.QueryKey.equals(QueryKey.java:59) Other examples - HHH-1331 or HHH-1691 That's why i'm tring to optimize them. Preparing test case... > QueryCache should not call EntityType.getReturnedClass() or do it fast > ---------------------------------------------------------------------- > > Key: HHH-1490 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490 > Project: Hibernate3 > Type: Improvement > Components: core > Versions: 3.1.2 > Environment: Hibernate 3.1.2, MySQL 5.0.18-nt > Reporter: Sergey Vladimirov > Priority: Minor > Attachments: patch.txt > > > org.hibernate.cache.QueryKey should not call EntityType.getReturnedClass() or do it fast, because EntityType.getReturnedClass() works with ClassLoader - i is very expensive operation: > Stack trace: > java.lang.ClassLoader.findLoadedClass0(Native Method) > java.lang.ClassLoader.findLoadedClass(ClassLoader.java:922) > java.lang.ClassLoader.loadClass(ClassLoader.java:295) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > java.lang.ClassLoader.loadClass(ClassLoader.java:251) > org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:95) > org.hibernate.type.EntityType.getReturnedClass(EntityType.java:91) > org.hibernate.cache.QueryKey.equals(QueryKey.java:59) > org.apache.commons.collections.map.AbstractReferenceMap.isEqualKey(AbstractReferenceMap.java:433) > org.apache.commons.collections.map.AbstractHashedMap.getEntry(AbstractHashedMap.java:434) > org.apache.commons.collections.map.AbstractReferenceMap.getEntry(AbstractReferenceMap.java:404) > org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:229) > ru.arptek.common.collections.SynchronizedMap.get(SynchronizedMap.java:94) > Operations with ClassLoaders is not falst enought for equals() operations. May be one should add some kind of caching (in EntityType, for example) or compare EntityType by class names, not by Class objects. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Sergey V. (JIRA) <no...@at...> - 2006-06-30 20:43:18
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490?page=comments#action_23511 ] Sergey Vladimirov commented on HHH-1490: ---------------------------------------- final int count = 1000000; for (int i = 0; i < count / 10; i++) { ReflectHelper .classForName("ru.arptek.common.java.lang.ClassLoadingVSClassCache"); } final long start = System.nanoTime(); for (int i = 0; i < count; i++) { ReflectHelper .classForName("ru.arptek.common.java.lang.ClassLoadingVSClassCache"); } final long end = System.nanoTime(); System.out.println((end - start) / count); At my machine (1.2GHz): - JDK 1.5.0_07 ~ 5 ms - JDK 1.6.0 (beta 2?) ~ 3.6 ms But it is milliseconds! There are at least one lock (locked sun.misc.Launcher$AppClassLoader@93dee9 ) and call to native method. Should i compare with variable obtaining? private Class class1; private Class getClass1() { return class1; } public void testGet() throws ClassNotFoundException { final int count = 1000000000; class1 = ReflectHelper .classForName("ru.arptek.common.java.lang.ClassLoadingVSClassCache"); for (int i = 0; i < count / 10; i++) { getClass1(); } final long start = System.nanoTime(); for (int i = 0; i < count; i++) { getClass1(); } final long end = System.nanoTime(); System.out.println((end - start) / count); } At my machine (1.2GHz): - JDK 1.5.0_07 ~ 3 ns (nano!!!) - JDK 1.6.0 (beta 2?) ~ 3 ns (nano!!!) > QueryCache should not call EntityType.getReturnedClass() or do it fast > ---------------------------------------------------------------------- > > Key: HHH-1490 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1490 > Project: Hibernate3 > Type: Improvement > Components: core > Versions: 3.1.2 > Environment: Hibernate 3.1.2, MySQL 5.0.18-nt > Reporter: Sergey Vladimirov > Priority: Minor > Attachments: patch.txt > > > org.hibernate.cache.QueryKey should not call EntityType.getReturnedClass() or do it fast, because EntityType.getReturnedClass() works with ClassLoader - i is very expensive operation: > Stack trace: > java.lang.ClassLoader.findLoadedClass0(Native Method) > java.lang.ClassLoader.findLoadedClass(ClassLoader.java:922) > java.lang.ClassLoader.loadClass(ClassLoader.java:295) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) > - locked sun.misc.Launcher$AppClassLoader@93dee9 > java.lang.ClassLoader.loadClass(ClassLoader.java:251) > org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:95) > org.hibernate.type.EntityType.getReturnedClass(EntityType.java:91) > org.hibernate.cache.QueryKey.equals(QueryKey.java:59) > org.apache.commons.collections.map.AbstractReferenceMap.isEqualKey(AbstractReferenceMap.java:433) > org.apache.commons.collections.map.AbstractHashedMap.getEntry(AbstractHashedMap.java:434) > org.apache.commons.collections.map.AbstractReferenceMap.getEntry(AbstractReferenceMap.java:404) > org.apache.commons.collections.map.AbstractReferenceMap.get(AbstractReferenceMap.java:229) > ru.arptek.common.collections.SynchronizedMap.get(SynchronizedMap.java:94) > Operations with ClassLoaders is not falst enought for equals() operations. May be one should add some kind of caching (in EntityType, for example) or compare EntityType by class names, not by Class objects. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |