[Hibernate-JIRA] Updated: (HHH-1258) startup time improvements
by Mike Quilleash (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258?page=all ]
Mike Quilleash updated HHH-1258:
--------------------------------
Attachment: AbstractEntityTuplizer.patch
Patch of AbstractEntityTuplizer attached.
> startup time improvements
> -------------------------
>
> Key: HHH-1258
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258
> Project: Hibernate3
> Type: Improvement
> Components: core
> Versions: 3.1 rc3
> Reporter: Max Rydahl Andersen
> Assignee: Max Rydahl Andersen
> Attachments: AbstractEntityTuplizer.patch, Environment.patch, SessionFactoryImpl.java, SessionFactoryImpl.patch
>
>
> while doing some basic startup perf testing the following were found - this issue is mainly to track what I find, and then fix it:
> Initial tests where 100 classes, 30 sec for buildSessionFactory
> setting hibernate.cglib.use_reflection_optimizer false and it is 10 sec for buildSessionFactory.
> (maybe we should autodetect which jdk we are running on and disable it per default for 1.4/1.5 - needs to validate runtime impact)
> Another (22%) time stealer is the discovery of getter/setters - in worst case it iterates over all declared methods per property.
> (alternatively we could cache/sort this list or make a more efficient implementation if a class only contain default property accessors)
> Other 20% of the time is done in net.sf.cglib related classes for build time enhancement.
> The rest of the time is Configuration creation (can be cached) and other iteration code.
> (p.s. don't take the % numbers as hard values - these are definitly affected by how many methods/classes you have; this underlying tests
> is done on pojos with a "high" method count (approx 100)
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years
[Hibernate-JIRA] Updated: (HHH-1258) startup time improvements
by Mike Quilleash (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258?page=all ]
Mike Quilleash updated HHH-1258:
--------------------------------
Attachment: Environment.patch
Patch of Environment added.
> startup time improvements
> -------------------------
>
> Key: HHH-1258
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258
> Project: Hibernate3
> Type: Improvement
> Components: core
> Versions: 3.1 rc3
> Reporter: Max Rydahl Andersen
> Assignee: Max Rydahl Andersen
> Attachments: Environment.patch, SessionFactoryImpl.java, SessionFactoryImpl.patch
>
>
> while doing some basic startup perf testing the following were found - this issue is mainly to track what I find, and then fix it:
> Initial tests where 100 classes, 30 sec for buildSessionFactory
> setting hibernate.cglib.use_reflection_optimizer false and it is 10 sec for buildSessionFactory.
> (maybe we should autodetect which jdk we are running on and disable it per default for 1.4/1.5 - needs to validate runtime impact)
> Another (22%) time stealer is the discovery of getter/setters - in worst case it iterates over all declared methods per property.
> (alternatively we could cache/sort this list or make a more efficient implementation if a class only contain default property accessors)
> Other 20% of the time is done in net.sf.cglib related classes for build time enhancement.
> The rest of the time is Configuration creation (can be cached) and other iteration code.
> (p.s. don't take the % numbers as hard values - these are definitly affected by how many methods/classes you have; this underlying tests
> is done on pojos with a "high" method count (approx 100)
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years
[Hibernate-JIRA] Commented: (HHH-1258) startup time improvements
by Mike Quilleash (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258?page=c... ]
Mike Quilleash commented on HHH-1258:
-------------------------------------
Hi there.
I was pointed to this by someone on the Tomcat user list (Tyler I think). I was looking for ways to speedup the hibernate startup. Previous debugging in hibernate2 showed that the vast majority of time was spent in the cglib code building the proxies. I've recently upgraded to hibernate3 so I thought I've have a crack myself.
I've followed the thought above about doing lazy setup at the Entity Persister level. I've modified the AbstractEntityTuplizer and Environment with a new option to lazily create the proxy factories the first time createProxy() is called rather than in the constructor. By default the old behaviour is used. It uses an inner class that implements ProxyFactory to wrap up the lazy intialisation.
New config option is:
hibernate.use_lazy_proxy_factory true
This resulted in speedup of the hibernate buildSessionFactory() call (~10s to ~1.5s) so about 6-7 times and a 2.5-3 speedup of my overall app startup time. I've only really done this for dev mode when a lot of restarts are required and I got bored of watching "building session factory".
It will an extremely useful little timesaver for me and other developers so I thought I'd post it here for anyone else to use and the hibernate team to use if they wish.
Dowsides of the solution are:
1) PersistentClass is kept in the lazy initialisation class for building the proxy factory. Could be nulled out when the proxy factory is built for the first time to get it GCed
2) Unsure about thread-safety regarding cglib. I'm pretty sure that the code is threadsafe but it may "see" an old null value in the LazyProxyFactory and create the factory again. Could just synchronise the getProxy() method. This has all been written so you can do whatever you want in the LazyProxyFactory without affecting anything when the new option is not specified.
3) The old code handled buildProxyFactory() returning null. I don't know if/how this happens. I would probably modify the lazy getProxy() to throw a descriptive exception if the buildFactory() returns null. ("hibernate.use_lazy_proxy_factory option is not compatible with the current proxy configuration. Please disable this option")
I'll attach the patches for the relevant patches shortly (once I figure out how to do a patch).
Cheers.
> startup time improvements
> -------------------------
>
> Key: HHH-1258
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1258
> Project: Hibernate3
> Type: Improvement
> Components: core
> Versions: 3.1 rc3
> Reporter: Max Rydahl Andersen
> Assignee: Max Rydahl Andersen
> Attachments: SessionFactoryImpl.java, SessionFactoryImpl.patch
>
>
> while doing some basic startup perf testing the following were found - this issue is mainly to track what I find, and then fix it:
> Initial tests where 100 classes, 30 sec for buildSessionFactory
> setting hibernate.cglib.use_reflection_optimizer false and it is 10 sec for buildSessionFactory.
> (maybe we should autodetect which jdk we are running on and disable it per default for 1.4/1.5 - needs to validate runtime impact)
> Another (22%) time stealer is the discovery of getter/setters - in worst case it iterates over all declared methods per property.
> (alternatively we could cache/sort this list or make a more efficient implementation if a class only contain default property accessors)
> Other 20% of the time is done in net.sf.cglib related classes for build time enhancement.
> The rest of the time is Configuration creation (can be cached) and other iteration code.
> (p.s. don't take the % numbers as hard values - these are definitly affected by how many methods/classes you have; this underlying tests
> is done on pojos with a "high" method count (approx 100)
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years
[Hibernate-JIRA] Created: (HHH-2108) org.hibernate.MappingNotFoundException: file:
by Courtney Arnold (JIRA)
org.hibernate.MappingNotFoundException: file:
----------------------------------------------
Key: HHH-2108
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2108
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.cr4
Environment: Hibernate 3.2.0cr4, SQL Server 2000
Reporter: Courtney Arnold
I receive the following error while trying to add a cacheable configuration file to the configuration:
org.hibernate.InvalidMappingException: Could not parse mapping document from file F:\products\common\resources\hibernate\hbm\org\waterford\product\data\db\hibernate\Product.hbm.xml
at org.hibernate.cfg.Configuration.addCacheableFile(Configuration.java:359)
at org.hibernate.cfg.Configuration.addCacheableFile(Configuration.java:364)
at org.waterford.common.data.db.hibernate.HibernateDbBroker._addMappings(HibernateDbBroker.java:568)
at org.waterford.common.data.db.hibernate.HibernateDbBroker._getConfiguration(HibernateDbBroker.java:477)
at org.waterford.common.data.db.hibernate.HibernateDbBroker._initSessionFactory(HibernateDbBroker.java:668)
at org.waterford.common.data.db.hibernate.HibernateDbBroker.setDb(HibernateDbBroker.java:189)
at org.waterford.sm.db.smdbinterface.HibSmDbInterface.connect(HibSmDbInterface.java:426)
at org.waterford.sm.db.smdbinterface.HibSmDbInterface.<init>(HibSmDbInterface.java:333)
at org.waterford.sm.db.smdbinterface.factory.HibSmDbInterfaceFactory._getInstance(HibSmDbInterfaceFactory.java:51)
at org.waterford.sm.db.smdbinterface.factory.HibSmDbInterfaceFactory.getInstance(HibSmDbInterfaceFactory.java:24)
at org.waterford.sm.license.LicenseManager._getDbInterface(LicenseManager.java:48)
at org.waterford.sm.license.LicenseManager.loadFromDB(LicenseManager.java:218)
at org.waterford.sm.license.LicenseManager.init(LicenseManager.java:183)
at org.waterford.sm.license.LicenseManager.initLicensing(LicenseManager.java:118)
at org.waterford.sm.SMFrame.init(SMFrame.java:284)
at org.waterford.sm.SMApp.<init>(SMApp.java:76)
at org.waterford.sm.SMApp.main(SMApp.java:213)
Caused by: org.hibernate.MappingNotFoundException: file: F:\products\common\resources\hibernate\hbm\org\waterford\product\data\db\hibernate\Product.hbm.xml not found
at org.hibernate.cfg.Configuration.addCacheableFile(Configuration.java:349)
... 16 more
I have looked at the source for org.hibernate.cfg.Configuration(addCacheableFile) and the problem lies in the if /else statement around line 348. Prior to this statement a cached configuration file was loaded into the "doc" object. So the if statement "if (doc == null && xmlFile.exists())" will return false. Doing so, execution continues on the else statement that executes "throw new MappingNotFoundException("file", xmlFile.toString());". Due to this, no cached files can be loaded into the configuration, only uncached files can be loaded. The else statement needs to be modified to be "else if (doc == null)".
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years
[Hibernate-JIRA] Commented: (HHH-1) Optimize Hibernate for the bulk insertion of related entities
by Martin Ross (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1?page=comm... ]
Martin Ross commented on HHH-1:
-------------------------------
Hi Michael,
Thanks for comments... I'm new to hibernate so not very clear on how everything works...
As for 1) I think the reason we need to traverse is the following...
Take four queued insert actions
Class Parent
{
int pk;
}
Class Child
{
int pk;
Parent parent;
}
Class Toy
{
int pk;
Child owner;
}
Class ManufactureDate
{
int pk;
Toy toy;
}
And a default (and correct) insertion order of:
Parent
Child
Toy
ManufactureDate
We want ManufactureDate.compareTo(Parent) ==1, yes? Under your implementation It will return 0. I found this out when I ran your code and tested it (along with my own changes). The problem is that we can't just rely on the fact that the items are sorted in the correct order before mergeSort() is called since compareTo can be called between any two items in the insertAction queue, not just immediate relations. And mergeSort() relies on a correct implementation of the compareTo() method to end up with a correctly sorted list although I guess if we used bubble sort instead of mergeSort we might be okay :)
Does this argument make sense to you? Am I missing something really simple? As far as I can tell we need a way to tell compareTo any two hibernate entities and the only way I can see this is to do a graph traversal.
2) This is basically what I added to my code when I was trying to get it to work.
3) I was referring to the wrinkle in implementing a graph traversal algorithm.
> Optimize Hibernate for the bulk insertion of related entities
> -------------------------------------------------------------
>
> Key: HHH-1
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1
> Project: Hibernate3
> Type: New Feature
> Components: core
> Environment: Hibernate 1.2, MySql 3.1
> Reporter: Bradley Leupen
> Priority: Minor
>
>
> It is currently difficult to batch the creation of persistent entities that maintain associations with other entities.
> Add necessary api to hibernate to support the save or update of a collection of entities. An optimization can be applied in this scenario to group inserts / updates by entity class, or table. This will enable the hibernate engine to utilize batching if available, drastically improving performance over a network.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years
[Hibernate-JIRA] Created: (HBX-829) Exception in QueryPageViewer
by Mike haller (JIRA)
Exception in QueryPageViewer
----------------------------
Key: HBX-829
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-829
Project: Hibernate Tools
Type: Bug
Components: eclipse
Versions: 3.2beta8
Reporter: Mike haller
If POJOs require thirdparty libraries which are not added to the classpath in the Hibernate Configuration, a lot of Exceptions occur. However, one of them is extremely annoying when it occurs as it is shown for *each* returned object in a HQL query result viewer. It is not possible to quit Eclipse in a clean way any more as the error message keeps popping up.
I suggest to catch problems occuring in the label provider and show them *once* in the problems view.
!ENTRY org.eclipse.jface 4 2 2006-11-22 13:48:00.053
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
!STACK 0
java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/ToStringBuilder
at com.example.SomePojo.toString(SomePojo.java:201)
at org.hibernate.eclipse.console.views.QueryPageViewer$LabelProviderImpl.getColumnText(QueryPageViewer.java:77)
at org.eclipse.jface.viewers.TableViewer.doUpdateItem(TableViewer.java:486)
at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRunnable.run(StructuredViewer.java:465)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:843)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149)
at org.eclipse.jface.viewers.StructuredViewer.updateItem(StructuredViewer.java:1955)
at org.eclipse.jface.viewers.TableViewer.createItem(TableViewer.java:350)
at org.eclipse.jface.viewers.TableViewer.internalRefreshAll(TableViewer.java:923)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:818)
at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:807)
at org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:1388)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1323)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1386)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1345)
at org.eclipse.jface.viewers.TableViewer.inputChanged(TableViewer.java:767)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:250)
at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1542)
at org.hibernate.eclipse.console.views.QueryPageViewer.createTable(QueryPageViewer.java:208)
at org.hibernate.eclipse.console.views.QueryPageViewer.createControl(QueryPageViewer.java:187)
at org.hibernate.eclipse.console.views.QueryPageViewer.<init>(QueryPageViewer.java:145)
at org.hibernate.eclipse.console.views.QueryPageTabView.rebuild(QueryPageTabView.java:109)
at org.hibernate.eclipse.console.views.QueryPageTabView.createPartControl(QueryPageTabView.java:151)
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years
[Hibernate-JIRA] Created: (HBX-817) Oracle
by Eric Kershner (JIRA)
Oracle
------
Key: HBX-817
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-817
Project: Hibernate Tools
Type: Patch
Components: reverse-engineer
Versions: 3.2beta8
Environment: Hibernate 3.2, Oracle 10g
Reporter: Eric Kershner
Attachments: OracleMetaDataDialect.java
Here is a patch for the OracleMetaDataDialect. The prior version dynamically built the query strings and executed them directly. Oracle cannot perform access path optimization and reuse the queries when performed this way. I changed the dialect to use PreparedStatements instead and increased the mapping generation by 30x. Additionally, I joined a couple more tables to the getTables and getColumns methods to read comments and assign those appropriately in the ResultSetIterator's convertRow methods. This allows access to table and column comments, which is helpful when generating javadoc meta attributes. This was tested on Oracle 10g (10.2.0.1.0) but needs testing on 9i, work estimate reflects the time necessary to test on 9i and run any appropriate unit tests.
When mapping 420 tables with a 1300 line reveng file:
Current OracleMetaDataDialect: 24 min 50 sec
JDBCMetaDataDialect: 1 min 50 sec
New OracleMetaDataDialect: 51 sec
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years, 1 month