Skip to content

Allocate postings enum buffers lazily - #17024

Open
uchiha-asha wants to merge 6 commits into
apache:mainfrom
uchiha-asha:lucene-perf-postings-lazy-buffers
Open

uchiha-asha wants to merge 6 commits into
apache:mainfrom
uchiha-asha:lucene-perf-postings-lazy-buffers

Conversation

@uchiha-asha

Copy link
Copy Markdown
Contributor

Every BlockPostingsEnum allocates a FixedBitSet even for PACKED encoding, and a freqBuffer array even when frequencies are not requested.
This change allocates the bitset on first use and shares a read-only all-ones frequency buffer across enums that do not need frequencies.
The change shows considerable timing and allocation gains in high-cardinality keyword sort and the single-segment 64-term disjunction.

Benchmarks: new JMH benchmarks (not part of this PR), baseline and patched lucene-core swapped on identical indexes, 3 forks x 5 iterations, 2 GB heap, JDK 25.0.5, a shared 4-vCPU cloud VM.

Workload Segments Baseline Patched Time change
Keyword sort, top 10 1 1,472 µs 796 µs −45.9%
Keyword sort, top 10 20 1,271 µs 878 µs −30.9%
OR of 64 IDs 1 281 µs 200 µs −28.9%
OR of 64 IDs 20 2,397 µs 2,201 µs −8.2%
OR of 1,024 IDs 1 5,041 µs 4,825 µs −4.3%
OR of 1,024 IDs 20 44,312 µs 38,928 µs −12.2
One dense term 1 1,335 µs 1,385 µs +3.8%
One dense term 20 1,404 µs 1,431 µs +1.9%
Workload Segments Baseline bytes/search Patched bytes/search Reduction
Keyword sort 1 3.69 MB 1.60 MB 56.6%
Keyword sort 20 2.07 MB 1.05 MB 49.3%
OR of 64 IDs 1 611 KB 476 KB 22.0%
OR of 1,024 IDs 20 119.53 MB 102.69 MB 14.1%

@uchiha-asha

Copy link
Copy Markdown
Contributor Author

@jpountz @msokolov Could you please review this when available. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant