Skip to content

chunkers: stale kernel comments, explicit kernel dispatch, kernel benchmark script - #10308

Merged
ThomasWaldmann merged 3 commits into
borgbackup:masterfrom
ThomasWaldmann:chunker-kernel-hygiene
Sep 2, 2026
Merged

chunkers: stale kernel comments, explicit kernel dispatch, kernel benchmark script#10308
ThomasWaldmann merged 3 commits into
borgbackup:masterfrom
ThomasWaldmann:chunker-kernel-hygiene

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Hygiene follow-ups from the chunker kernel audit, one commit each, no change to cut points or (intended) behaviour:

  1. Stale comments and docstrings in the kernels: the avx2 double-buffer notes claimed the store-forwarding stall "disappears" (perf counters on Zen 4 show 4 failed forwards per block remain), fastcdc_impl.h described the unknown-id fallback inverted, the goldilocks branchless-reduction note only holds for gcc -O2/clang (gcc -O3 re-introduces a conditional jump, marked TODO), the EVP path's digest recompute at a cut is unused by the chunker, chunkers/__init__.py said kernels default to "the simplest implementation", and the AES chunkers' kernel docstring lacked vaes.
  2. scripts/bench_chunker_kernels.py: the chunkers x kernels throughput table used to decide the per-platform defaults in borg2: benchmarking needed #10160, added to the repo. It now understands that borg benchmark cpu --chunking --json reports a chunker it cannot construct as an {"error": ...} row with exit 0 (the previous version of the script found "no selectable kernels" against current master because of that).
  3. Explicit kernel dispatch: fc_scan() / bz64_scan() ran the platform's vector kernel for any unknown id (AVX2 on x86-64, which would SIGILL on a CPU without it). Callers validate ids, so it was latent; now every id has its case and unknown ids run the portable blockwise kernel, with *_kernel_name() saying so.

Verified: chunker test suite on macOS (Apple clang 17), kernel selection unchanged, the script's smoke run works against this build.

🤖 Generated with Claude Code

ThomasWaldmann and others added 3 commits September 2, 2026 02:08
- the avx2 kernels' double-buffer notes claimed the store-to-load
  forwarding stall "disappears"; performance counters on a Zen 4 show
  4 failed forwards per block remain (the loads are wider than the
  stores, so they can only wait for the stores to commit). Say what the
  double buffer does and does not achieve, without the history.
- fastcdc_impl.h said an unknown kernel id falls back to the vector
  kernel; it is the blockwise kernel (see the dispatch commit).
- goldilocks: the branchless-reduction note is only true for gcc -O2
  and clang; gcc -O3 turns the final compare-and-select back into a
  conditional jump (marked TODO).
- phte_scan.h: the digest recomputed at a cut in the EVP path is not
  used by the chunker; say why it is still computed.
- chunkers/__init__.py and phte_chunker.pyx: the kernel default is
  chosen per platform, not "the simplest implementation", and the AES
  chunkers' kernel property can also say 'vaes'.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rk table

Drives `borg benchmark cpu --chunking --json` once per scan kernel
combination and prints one throughput table over all chunkers and all
kernels this build and CPU can run, which is how the per-platform kernel
defaults were and are decided (borgbackup#10160).

`borg benchmark cpu` reports a chunker it cannot construct - e.g. because
an unusable kernel was requested - as an {"error": ...} row and carries on
with exit code 0, so the script treats such a row as the run's failure;
that is also how it discovers which kernels exist (an invalid name makes
borg list the valid ones).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…se kernel

fc_scan() and bz64_scan() ran the platform's vector kernel for any kernel
id they did not know - on x86-64 that is the AVX2 kernel, which would
SIGILL on a CPU without AVX2. Callers validate the id first, so this was
latent; now every id has its case and anything else runs the portable
blockwise kernel, and fc_kernel_name() / bz64_kernel_name() say so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.70%. Comparing base (71dc70e) to head (37ffec4).
⚠️ Report is 15 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10308      +/-   ##
==========================================
+ Coverage   87.56%   87.70%   +0.14%     
==========================================
  Files         103      103              
  Lines       18686    18712      +26     
  Branches     2875     2880       +5     
==========================================
+ Hits        16362    16411      +49     
+ Misses       1622     1600      -22     
+ Partials      702      701       -1     

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

@ThomasWaldmann
ThomasWaldmann merged commit 7d3755e into borgbackup:master Sep 2, 2026
26 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the chunker-kernel-hygiene branch September 2, 2026 09:22
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.

1 participant