perf(moarstats): hint rare branches with core::hint::cold_path()#3823
Merged
jqnatividad merged 2 commits intomasterfrom May 5, 2026
Merged
perf(moarstats): hint rare branches with core::hint::cold_path()#3823jqnatividad merged 2 commits intomasterfrom
jqnatividad merged 2 commits intomasterfrom
Conversation
Mark exceptional branches inside the per-record hot loops of `count_chunk_outliers` and `compute_chunk_bivariate` as cold so the compiler can keep the common path tight: - UTF-8 decode failures on byte cells (CSV cells are virtually always valid UTF-8) - `chunk_stats.get_mut` "this can't happen" safety guards already paired with `debug_assert!(false, ...)` Leaf `compute_*` finalizer helpers, `is_empty()` checks in the parsers, and the outlier-bucket if/else chain were intentionally not hinted — they are not on a tight inner loop or their branch frequency depends on the dataset. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
Address roborev review #1956 (Low): move `use core::hint::cold_path;` to the top of the import block, matching the convention in `src/cmd/stats.rs`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
core::hint::cold_path()hints to exceptional branches inside the per-record hot loops ofcount_chunk_outliersandcompute_chunk_bivariate, matching the pattern already used instats.rs,frequency.rs, andvalidate.rs.chunk_stats.get_mutsafety guards already paired withdebug_assert!(false, ...).compute_*finalizer helpers (called O(columns), not in a tight loop),is_empty()checks inparse_float_opt*/parse_date_to_days(empty cells are common in real CSVs), and the outlier-bucket if/else chain (whole purpose of that loop is counting outliers — can't assume "normal" is hot).Test plan
cargo build --locked --bin qsv -F all_features— cleancargo test moarstats -F all_features— 88 passed, 0 failedcargo clippy --bin qsv -F all_features -- -D warnings— clean🤖 Generated with Claude Code