herley-shaori opened a new pull request, #15824:
URL: https://github.com/apache/lucene/pull/15824

   ## Summary
   
   Fixes #15820
   
   The lucene103 blocktree codec replaced the in-memory FST term index with an 
on-disk `TrieReader` backed by memory-mapped `RandomAccessInput`. Every 
`readLong`/`readByte` call on the mmap triggers Panama Foreign Memory API 
bounds checks (`MemorySessionImpl.checkValidStateRaw()`), causing a **~6x 
regression** in `seekExact` performance compared to the lucene90 FST which was 
always heap-resident.
   
   This PR loads the trie index bytes into a heap-backed `ByteBuffersDataInput` 
at `TermsEnum` creation time in `FieldReader.newReader()`, so that trie 
navigation uses pure Java array reads instead of mmap reads.
   
   ### Why this works
   
   - `ByteBuffersDataInput` backed by a single heap `ByteBuffer` takes the fast 
path: `blocks[0].getLong(blockOffset)` — a direct Java array read with no mmap 
or Panama bounds checks
   - The trie index is typically small relative to the terms data, so heap 
overhead is minimal
   - This matches the lucene90 behavior where the FST term index was always 
heap-resident
   
   ### Changes
   
   - **`FieldReader.java`**: Modified `newReader()` to read the trie index 
slice into a `byte[]`, wrap it in 
`ByteBuffersDataInput`/`ByteBuffersIndexInput`, and pass the heap-backed input 
to `TrieReader`
   - **`CHANGES.txt`**: Added optimization entry under Lucene 11.0.0
   
   ## Test plan
   
   - [x] All existing blocktree tests pass (`TestTrie`, etc.)
   - [x] All Lucene103/104 codec tests pass (869+ tests)
   - [x] Code formatting verified via `./gradlew tidy`
   - [ ] Benchmark seekExact throughput with UUID-based _id field across many 
segments to validate regression fix


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to