Speed up reading history operations from Lucene - #22603
Conversation
Previously when reading history, every document would fetch a fresh StoredFields instance, which decompress that compression block for every document. This optimization detects a contiguous gapless range of docIDs and serves them from the same (sequential) stored fields reader. The optimization is gated on the same thread that created the StoredFields instance must read it, as Lucene documents that instances are not safe to hand across threads. Additionally, a min batch size threshold must be met to avoid decompress the block eagerly in the case where it does not matter. Benchmark results: ┌────────────────────┬──────────┬─────────┐ │ layout │ baseline │ change │ ├────────────────────┼──────────┼─────────┤ │ CONTIGUOUS │ 331 ms │ 19.2 ms │ ├────────────────────┼──────────┼─────────┤ │ STRIDED (stride 2) │ 379 ms │ 324 ms │ ├────────────────────┼──────────┼─────────┤ │ INTERLEAVED │ 334 ms │ 312 ms │ └────────────────────┴──────────┴─────────┘ Signed-off-by: Andrew Ross <andrross@amazon.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
❌ Gradle check result for 3ff67c4: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
FYI @jainankitk @rishabhmaurya I'm deliberately starting small here. The check to use this optimization is narrow enough that I don't see any feasible downside to this. The INTERLEAVED case is the next case that would be worth optimizing in my opinion, as newly created segments under heavy indexing are often interleaved. Things get more complicated because we'll have to hold some of the decompressed state in memory, which means defining some bounds and more extensive testing to ensure we don't introduce regressions. |
|
❌ Gradle check result for 3ff67c4: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22603 +/- ##
=========================================
Coverage 71.39% 71.39%
- Complexity 76760 76797 +37
=========================================
Files 6148 6148
Lines 357951 357980 +29
Branches 52170 52177 +7
=========================================
+ Hits 255556 255596 +40
- Misses 82024 82077 +53
+ Partials 20371 20307 -64 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Previously when reading history, every document would fetch a fresh StoredFields instance, which decompress that compression block for every document. This optimization detects a contiguous gapless range of docIDs and serves them from the same (sequential) stored fields reader.
The optimization is gated on the same thread that created the StoredFields instance must read it, as Lucene documents that instances are not safe to hand across threads. Additionally, a min batch size threshold must be met to avoid decompress the block eagerly in the case where it does not matter.
Benchmark results:
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.