Nuno Santos created OAK-12413:
---------------------------------

             Summary: Pre-size predictable ArrayList allocations in the 
compaction write path
                 Key: OAK-12413
                 URL: https://issues.apache.org/jira/browse/OAK-12413
             Project: Jackrabbit Oak
          Issue Type: Improvement
          Components: segment-tar
            Reporter: Nuno Santos


Several {{ArrayList}}s allocated in {{DefaultSegmentWriter}}'s write/compaction 
path (e.g. the map-entry list built from {{changes}}, the leaf-bucket list 
built from map buckets, the property value-id list, and the node/property id 
lists built while writing a node) start at the default initial capacity and 
grow by repeated internal array reallocation and copy as elements are added — 
even though their eventual size is already known at the allocation site (e.g. 
{{changes.size()}}, {{newSize}}, {{state.count()}}, 
{{template.getPropertyTemplates().length}}).

Pre-size these lists using the already-available size hint ({{new 
ArrayList<>(knownSize)}}) to avoid the repeated growth/copy, which happens on 
every node, property and map entry written during compaction.

No behavioral change intended.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to