nfsantos opened a new pull request, #3151:
URL: https://github.com/apache/jackrabbit-oak/pull/3151

   ## Summary
   `AbstractRemoteSegmentArchiveReader#readSegment(long, long)` and 
`#containsSegment(long, long)` are called once per segment reference and are on 
the hot path of online compaction. They previously looked 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` now uses it instead of a `UUID`-keyed 
map. `getSegmentUUIDs()` (not on the hot path) still returns `UUID`s, built 
lazily from the index's entries (reusing each entry's already-computed `UUID`).
   - As a side effect, this also fixes a latent bug: two blobs sharing the same 
segment identifier (e.g. after a retry) would make the previous 
`Map.ofEntries(...)`-based index construction throw `IllegalArgumentException` 
on the duplicate key. The new index instead keeps the entry with the greatest 
position, as the surrounding code intends.
   
   Jira: https://issues.apache.org/jira/browse/OAK-12417
   
   ## Test plan
   - `mvn -pl oak-segment-remote test 
-Dtest=SegmentIndexTest,AbstractRemoteSegmentArchiveReaderTest,RemoteSegmentArchiveEntryTest`
 — 7/7, 12/12, 8/8 pass. `SegmentIndexTest` is new and covers 
empty/present/absent lookups, duplicate-key "latest position wins" semantics 
(in both insertion orders), growth beyond initial capacity (5000 random 
entries), and `values()`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to