Nuno Santos created OAK-12417:
---------------------------------
Summary: 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
{{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}} and
{{RemoteSegmentArchiveEntry}} are updated to use it instead of a {{UUID}}-keyed
map; {{RemoteSegmentArchiveEntry#getUuid()}} (only used for that map key) is
removed since it is no longer needed. {{getSegmentUUIDs()}} (not on the hot
path) still returns {{UUID}}s, built lazily from the index.
Same "latest position wins" semantics are preserved when multiple blobs share
the same segment identifier (e.g. after a retry).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)