Skip to content

Conversation

@folkertdev
Copy link
Member

Here we work around 2 issues in rustc/llvm:

  • A three-way compare using Ord::cmp is less efficient than an if-else sequence
  • Loops over inclusive ranges a..=b are less efficient than loops over exclusive ranges

loops over inclusive (a..=b) ranges are known to cause issues in LLVM. Here the impact is especially large,

Benchmark 2 (416 runs): target/relwithdebinfo/examples/compress rs 1 tests/input/quick/sample3.ref
  measurement          mean ± σ            min … max           outliers         delta
  wall_time          12.0ms ±  236us    11.6ms … 15.8ms         23 ( 6%)        ⚡-  5.2% ±  0.3%
  peak_rss           3.20MB ± 68.7KB    3.01MB … 3.28MB          0 ( 0%)          +  0.1% ±  0.3%
  cpu_cycles         47.7M  ±  937K     46.5M  … 64.1M          17 ( 4%)        ⚡-  5.7% ±  0.2%
  instructions        215M  ±  313       215M  …  215M           5 ( 1%)        ⚡-  6.3% ±  0.0%
  cache_references   4.63M  ±  107K     4.24M  … 5.10M           8 ( 2%)          +  0.5% ±  0.3%
  cache_misses        253K  ± 31.8K      109K  …  362K           7 ( 2%)        ⚡-  9.4% ±  1.7%
  branch_misses      82.7K  ±  385      82.2K  … 89.1K          29 ( 7%)          -  0.6% ±  0.1%
@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Flag Coverage Δ
fuzz-compress_then_decompress 51.08% <100.00%> (ø)
fuzz-decompress_chunked 30.06% <0.00%> (-2.75%) ⬇️
test-aarch64-apple-darwin 90.08% <100.00%> (-0.01%) ⬇️
test-x86_64-apple-darwin 90.18% <100.00%> (-0.01%) ⬇️
test-x86_64-unknown-linux-gnu 90.08% <100.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
libbz2-rs-sys/src/blocksort.rs 98.97% <100.00%> (-0.01%) ⬇️

... and 2 files with indirect coverage changes

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

@folkertdev folkertdev changed the title Fallback sort optimize fallback_sort Jun 16, 2025
@folkertdev folkertdev requested a review from bjorn3 June 16, 2025 10:37
@folkertdev folkertdev merged commit 5bb1f07 into main Jun 16, 2025
23 checks passed
@folkertdev folkertdev deleted the fallback-sort branch June 16, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants