Commit 7d611f0
perf(moarstats): hint rare branches with core::hint::cold_path() (#3823)
* perf(moarstats): hint rare branches with `core::hint::cold_path()`
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>
* style(moarstats): group `cold_path` import with `core`/`std` block
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>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a177270 commit 7d611f0
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| |||
1970 | 1971 | | |
1971 | 1972 | | |
1972 | 1973 | | |
1973 | | - | |
| 1974 | + | |
| 1975 | + | |
1974 | 1976 | | |
1975 | 1977 | | |
1976 | 1978 | | |
| 1979 | + | |
1977 | 1980 | | |
1978 | 1981 | | |
1979 | 1982 | | |
| |||
1987 | 1990 | | |
1988 | 1991 | | |
1989 | 1992 | | |
| 1993 | + | |
1990 | 1994 | | |
1991 | 1995 | | |
1992 | 1996 | | |
| |||
2303 | 2307 | | |
2304 | 2308 | | |
2305 | 2309 | | |
| 2310 | + | |
2306 | 2311 | | |
2307 | 2312 | | |
2308 | 2313 | | |
| |||
2313 | 2318 | | |
2314 | 2319 | | |
2315 | 2320 | | |
| 2321 | + | |
2316 | 2322 | | |
2317 | 2323 | | |
2318 | 2324 | | |
| |||
2328 | 2334 | | |
2329 | 2335 | | |
2330 | 2336 | | |
| 2337 | + | |
2331 | 2338 | | |
2332 | 2339 | | |
2333 | 2340 | | |
| |||
2357 | 2364 | | |
2358 | 2365 | | |
2359 | 2366 | | |
| 2367 | + | |
2360 | 2368 | | |
2361 | 2369 | | |
2362 | 2370 | | |
| |||
0 commit comments