[ 
https://issues.apache.org/jira/browse/OAK-12417?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Reschke closed OAK-12417.
--------------------------------

> Avoid UUID allocation and add O(1) index for in-archive segment lookup
> ----------------------------------------------------------------------
>
>                 Key: OAK-12417
>                 URL: https://issues.apache.org/jira/browse/OAK-12417
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>            Reporter: Nuno Santos
>            Priority: Major
>             Fix For: 2.8.0
>
>
> {{AbstractRemoteSegmentArchiveReader#readSegment(long, long)}} and 
> {{#containsSegment(long, long)}} are called once per segment reference and 
> are on the hot path of online compaction. They currently look up a 
> {{Map<UUID, RemoteSegmentArchiveEntry>}}, which requires allocating a new 
> {{UUID}} object for every call just to use as a lookup key, plus paying for 
> {{UUID.hashCode()}}/{{equals()}} through a generic {{HashMap}}.
> * Add a small, package-private open-addressing map ({{SegmentIndex}}) keyed 
> directly on the raw {{(msb, lsb)}} long pair, built once per archive open 
> ({{SegmentIndex.Builder}}, not on a hot path) and queried without any 
> per-lookup allocation.
> * {{AbstractRemoteSegmentArchiveReader}} is updated to use it instead of a 
> {{UUID}}-keyed map. {{getSegmentUUIDs()}} (not on the hot path) still returns 
> {{UUID}}s, built lazily from the index's entries by reusing each entry's 
> existing {{RemoteSegmentArchiveEntry#getUuid()}}.
> * Also gives a modest reduction in the index's steady-state memory footprint: 
> the previous {{Map<UUID, RemoteSegmentArchiveEntry>}} (built via 
> {{Map.ofEntries}}, which returns an immutable {{MapN}}) stores its entries in 
> a single flat {{Object[]}} table sized to hold both keys and values, reusing 
> the {{UUID}} each {{RemoteSegmentArchiveEntry}} already carries as the key, 
> so no extra {{UUID}} or node/wrapper object is allocated per entry there 
> either. {{SegmentIndex}}'s table only needs to hold the 
> {{RemoteSegmentArchiveEntry}} reference itself, since the identifier is 
> hashed on lookup rather than stored, so its array is roughly half the size of 
> the old one.



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

Reply via email to