[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6973) Reduce cache entry size by using long[] instead of ArrayList<Long> for queries and collections values

Adrien (JIRA) noreply at atlassian.com
Mon Jan 16 11:22:09 EST 2012


Reduce cache entry size by using long[] instead of ArrayList<Long> for queries and collections values
-----------------------------------------------------------------------------------------------------

                 Key: HHH-6973
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6973
             Project: Hibernate ORM
          Issue Type: Improvement
          Components: caching (L2)
    Affects Versions: 3.6.9
            Reporter: Adrien
            Priority: Minor
         Attachments: patch.zip

A lot of cacheable queries and cacheable collections are stored in L2 as an ArrayList of the primary key of the target entities. Most of the time, this primary key are Integer or Long. By storing this value as primitive array (int[] or long[]), I was able to divide the size of the entry cache by two on a classic web project. There is no thousands of Integer instances in memory anymore (32 bytes per instance), but a clean, compact array (4 or 8 x array size bytes).

Since Hibernate cache is the main use of the memory in a classic ORM project, it allows to have more queries and collections in memory, greatly improving the use of the cache.

I provide a sample patch of the correction for Integer primary key. It still needs a lot of improvements (Long primary key, optimisation, better dectection of the primary key type, unstructured storage in cache), but it is the general idea.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list