[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1612) Serious performance lost within IdentityMap...

Markus Heiden (JIRA) noreply at atlassian.com
Wed Nov 8 05:31:27 EST 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1612?page=comments#action_25211 ] 

Markus Heiden commented on HHH-1612:
------------------------------------

The IdentityMap seems to be the problem at first, but it isn't the real problem. I replaced the entrySet() method with a simpler one which directly iterates the underlying maps entrySet to avoid the massive useless object generation of the current implementation. Sadly, it didn't fix the performance bottleneck, it decreased the needed time but saving transient instances is still far to slow.

The real problem is the iteration in StatefulPersistenceContext's methods getOwnerId and getIndexInOwner which iterate each time over all known persistent entities.  This leads to an exponential increasing time by the number of currently known persistent entities. The called methods isFoundInParent and getIndexInParent didn't take long to execute but they are called so often that this accumulates to a significant time.

Just an example of the time needed by the original hibernate 3.2 implementation: I tried to save 1000 transient instances which each contained a collection with 10 transient instances which each contained a collection of 20 transient instances (~200000 transient instances total). This took over an hour!

> Serious performance lost within IdentityMap...
> ----------------------------------------------
>
>          Key: HHH-1612
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1612
>      Project: Hibernate3
>         Type: Improvement

>   Components: core
>     Versions: 3.1.3
>     Reporter: Peter Fassev
>     Priority: Critical
>  Attachments: Hibernate_3.1.3_performance.jpg
>
>
> Please look at the attached profiler snapshot.
> After I switched from 3.0.5 to 3.1.3 I have mentioned a serious performance decrease when perfecting data, especially on loading non lazy collection (for instance Arrays of String[]). A simple fetch query, which was executed in 6 seconds on hibernate 3.0.5, now it takes 40 seconds on 3.1.3 (without any changes to the application). The fetch of the whole data needs with 3.1.3 about 90 seconds, with 3.0.5 about 49, which is a serious performance lost.
> The NetBeans Profiler shows a huge increase of the self time of the IdentityMap.entrySet() method. Now it takes 22,3% of the whole start time. Together with it's calling method BatchFetchQueue.getCollectionBatch() it consumes 36 % of the start time, which explains the performance lost pretty good. 
> Looking at the source code I saw that there is already a TO DO regarding the performance of the IdentityMap.entrySet(), so please fix it, if possible. I think the whole implementation of the IdentityMap should be rethinked, because currently only a dirty hack is possible. If you can't use the IdentityHashMap of 1.4 due to compatibility reasons, please take a look at the current release of apache commons-collections (3.1), where you will find an IdentityHashMap.
> With best regards
> Peter

-- 
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




More information about the hibernate-issues mailing list