Skip to content

[MOD-14948] TopK Numeric micro benchmarks - #10724

Merged
ThierryBerger merged 3 commits into
masterfrom
thierry-14948
Aug 17, 2026
Merged

ThierryBerger merged 3 commits into
masterfrom
thierry-14948

Conversation

@ThierryBerger

@ThierryBerger ThierryBerger commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds benchmarks to compare Rust against C implementation for numeric top K.

Current findings are that current Rust implementation is slower ⚠️ ; but below is a list of possible improvements we'll tackle in follow ups, where cumulative improvements are promising.

Noise is around 4%, table reports median times

benchmark Rust C ratio
filtered n10k k10 24.42 µs 12.39 µs 1.97
filtered n10k k100 57.52 µs 36.95 µs 1.56
filtered n100k k10 61.61 µs 30.30 µs 2.03
filtered n100k k100 64.15 µs 35.11 µs 1.83
unfiltered n10k k10 168.6 µs 17.40 µs 9.69
unfiltered n10k k100 176.4 µs 28.77 µs 6.13
unfiltered n100k k10 487.0 µs 37.96 µs 12.83
unfiltered n100k k100 502.7 µs 52.72 µs 9.54
selectivity 1% child 373.7 µs 166.6 µs 2.24
selectivity 10% child 64.66 µs 34.95 µs 1.85
selectivity 50% child 66.44 µs 54.88 µs 1.21
expensive child, 1% 385.6 µs 194.5 µs 1.98
expensive child, 10% 103.2 µs 92.02 µs 1.12
expensive child, 50% 136.5 µs 161.3 µs 0.85

Follow ups:

Details

  • Size the unfiltered window from k instead of leaving it unbounded (was resolving the whole
    field, then materializing 8 ranges before the heap could stop it).
  • Skip the cross-batch de-duplication set and the coalescing pass on single-valued fields — a
    document can only be reached twice by a value-ordered scan if it carries several values.
    • tracked by MOD-17353
  • Merge the batch's already-sorted per-range runs instead of re-sorting the concatenation.
    • in C, Nothing is materialized, so nothing is ever out of order, that's a design decision we were worried about.
  • Let the filter child drive materialization, so index blocks holding no candidate are never
    decoded.

Final:

benchmark Rust C ratio
filtered n10k k10 11.85 µs 12.68 µs 0.93
filtered n10k k100 25.91 µs 38.26 µs 0.68
filtered n100k k10 29.23 µs 30.39 µs 0.96
filtered n100k k100 31.38 µs 35.00 µs 0.90
unfiltered n10k k10 11.53 µs 17.55 µs 0.66
unfiltered n10k k100 16.50 µs 28.54 µs 0.58
unfiltered n100k k10 25.76 µs 38.16 µs 0.67
unfiltered n100k k100 31.50 µs 52.68 µs 0.60
selectivity 1% child 166.5 µs 167.0 µs 1.00
selectivity 10% child 31.52 µs 35.00 µs 0.90
selectivity 50% child 45.52 µs 53.92 µs 0.84
expensive child, 1% 230.2 µs 195.6 µs 1.18
expensive child, 10% 77.81 µs 92.97 µs 0.84
expensive child, 50% 145.8 µs 161.0 µs 0.91

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

If a release note is required (bug fix / new feature / enhancement), describe the user impact of this PR in the title.

@github-actions github-actions Bot added the size:L label Aug 3, 2026
@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.05%. Comparing base (5d87f55) to head (cdb18f7).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10724      +/-   ##
==========================================
- Coverage   83.00%   82.05%   -0.96%     
==========================================
  Files         607      632      +25     
  Lines       80798    82045    +1247     
  Branches    35690    37223    +1533     
==========================================
+ Hits        67068    67323     +255     
- Misses      13391    14379     +988     
- Partials      339      343       +4     
Flag Coverage Δ
flow 84.33% <ø> (+0.34%) ⬆️
unit 55.53% <ø> (-0.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 660d79ccc8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Base automatically changed from thierry-mod-14945 to master August 11, 2026 13:53
@github-actions github-actions Bot added size:XL and removed size:L labels Aug 11, 2026
Drives the real C OptimizerIterator through a shim over the same range tree,
doc table and search context the Rust source reads, so both sides share one
fixture. A preflight asserts both return the same result count before any
timing is recorded.
@sonarqubecloud

Copy link
Copy Markdown

@ThierryBerger
ThierryBerger requested a review from memark August 12, 2026 10:04
@ThierryBerger
ThierryBerger requested a review from GuyAv46 August 13, 2026 12:58
@ThierryBerger
ThierryBerger added this pull request to the merge queue Aug 17, 2026
Merged via the queue into master with commit b826258 Aug 17, 2026
53 checks passed
@ThierryBerger
ThierryBerger deleted the thierry-14948 branch August 17, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants