praveenc7 opened a new pull request, #18732:
URL: https://github.com/apache/pinot/pull/18732
Resolving a large IN-list against a STRING dictionary spent significant CPU
and GC in ValueReaderComparisons: every binary-search probe allocated a
`ByteBuffer` to wrap the query bytes. Read the query bytes directly via
`byteArrayViewVarHandle` (JDK11+).
Sample Query
```
SELECT distinct(col1)
FROM table
WHERE col1 IN ('-7665553893770959315','-6082932782938102490', … hundreds
of values …)
```
Served at high QPS (~6K). The filter column is a high-cardinality STRING
dictionary, and each query carries a large IN-list.
Profiling
<img width="1804" height="930" alt="Screenshot 2026-06-07 at 2 25 48 PM"
src="https://github.com/user-attachments/assets/6964148e-5733-42ef-a711-3c771e7ed5a9"
/>
The flame graph shows the time is spent before any rows are scanned — in
resolving the IN-list literals to per-segment dictionary IDs (this runs once
per segment, on every query). The hot stack is:
```
FilterPlanNode.constructPhysicalOperator →
PredicateEvaluatorProvider.getPredicateEvaluator →
InPredicateEvaluatorFactory.newDictionaryBasedEvaluator →
PredicateUtils.getDictIdSet →
BaseImmutableDictionary.getDictIdsDivideBinarySearch → binarySearch →
FixedByteValueReaderWriter.compareUtf8Bytes →
ValueReaderComparisons.compareUtf8Bytes / mismatch.
```
This single comparison path accounts for ~66% of CPU. Each binary-search
probe wraps the query bytes in a freshly allocated ByteBuffer, so at this QPS
the per-probe allocation also drives heavy GC pressure — both of which this
change removes.
## Testing
JMH BenchmarkStringInListLookup — 1M-cardinality STRING dictionary of bare
numeric strings, 500-value IN-list,
| Benchmark | Metric | Baseline | Patched | Delta |
|---|---:|---:|---:|---:|
| `getDictIds` (`DIVIDE_BINARY_SEARCH`) | Throughput | 17.1 ops/ms | 26.7
ops/ms | +56% |
| | Alloc/op | 366,579 B | 24,136 B | −93% (15× less) |
| | GC count / time | 42 / 25 ms | 4 / 3 ms | ~10× less |
| `indexOf` isolated compare | Throughput | 12.5 ops/ms | 20.3 ops/ms | +62%
|
| | Alloc/op | 564,884 B | 20,002 B | −96% (28× less) |
--
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]