After upgrading my hibernate core version from 3.6.10.Final to 4.1.4.Final, I'm experiencing a significant reduction in performance when inserting any of my domain objects (~10x slower to insert).
The following is the latest statistics I have from a simplified test case, in which I populate my domain object, save it using a call to EntityManager.persist(), and then flush and commit the associated transaction:
- 3.6.10.Final - Averages 12ms per record to save - 4.1.4.Final - Averages 124ms per record to save
My test loops through and does this for N number of domain objects, with the only difference in each object being a newly generated id for the purpose of uniqueness. The same local database is used for testing, and the results can be reproduced consistently over multiple runs.
The object I am saving does have a large object graph (it's linked to many other domain objects, who in turn have further associations) - but my test case only populates the properties mapped directly under the main object. Modifying my test case to include linked collection information, yields similar results (both hibernate versions take longer, but the 4.1.4.Final version is always around 10x slower than 3.6.10.Final)
By debugging through a patched version of the hibernate-core code, I've seen that the later versions of hibernate seem to be spending a considerably higher amount of time trying to prepare the entity flushes of cascaded properties (EntityInsertAction -> ... --> Cascade, etc.). I have also confirmed that it is NOT the actual insert on the database that is taking the additional time.
I've been unable to test with Hibernate-Core versions from 4.0.0 -> 4.1.3, as the connection fails due to https://hibernate.atlassian.net/browse/HHH-7101. Because of this, the best I can conclude is that somewhere between 3.6.10, and 4.1.4 there was a change made which has negatively impacted performance. Upgrading to the very latest versions yields the same results - slow all the way up to version 4.3.10 (and presumably, beyond in the 5.0 alpha releases).
Initially I thought that perhaps https://hibernate.atlassian.net/browse/HHH-6848 may have been the culprit - however I reverted this manually from a patched version of Hibernate-Core 4.1.4, re-ran my test scenario, and noted that the performance was still just as slow.
Any suggestions or recommendations anyone could offer would be much appreciated.
|