RamakrishnaChilaka opened a new pull request, #15898: URL: https://github.com/apache/lucene/pull/15898
### Description LongValueFacetCutter's `nextOrd()` calls `computeIfAbsent()` on every document, which acquires a `ReadWriteLock.readLock()` each time — even when the value has already been seen. With low-cardinality fields (e.g. 1K distinct values across 500K docs), ~99.8% of these lock acquisitions are wasted. This PR adds a per-leaf `LongIntHashMap` that caches `value → ordinal` mappings. On cache hit (the common case), ordinal resolution is a plain unsynchronized hash map get. On cache miss (first occurrence of a value in the segment), it falls through to the existing locked `computeIfAbsent` and stores the result locally. ### JMH Benchmark (500K docs, 1K cardinality, Corretto JDK 25.0.2) | Benchmark | Single-valued | Multi-valued | |--------------------------|-----------------------|-----------------------| | matchAll (before) | 57.17 ops/s | 23.95 ops/s | | matchAll (after) | **76.44 ops/s (+34%)**| **30.43 ops/s (+27%)**| | filteredRange (before) | 554.06 ops/s | 239.78 ops/s | | filteredRange (after) | **655.63 ops/s (+18%)**| **278.14 ops/s (+16%)**| -- 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]
