enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

PropertyTree memory overuse #10534

Closed rymsha closed 4 months ago

rymsha commented 5 months ago

after #10015 was implemented we noticed extreme heap usage increase on some setups. The consumption is very high for NodeVersion objects, specifically the ones with big amount of KV records in data.

A lot of memory is wasted because each property value is represented by an ArrayList with 1 element - wasting 9 reserved cells (This is how mutable ArrayList works). Additionally PropertyArray object also wastes a lot of memory - because it uses HashMap. And When there are a bot more than 3000 elements in it 8192 elements are allocated.

rymsha commented 4 months ago

In order to save memory a separate representation of PropertyTree was introduced - specifically for cache.

By storing single KV elements without a List (just a reference to a Value) and storing PropertySets in a List (or just value) we managed to shrink PropertyTree 3.8 MB object into ImputableProperty 1.9 MB object with a greater copy performance as well