Skip to content

v0.0.14: Per-benchmark gates, tak detect, tak log, local baselines and commit backfill

Choose a tag to compare

@jdx jdx released this 02 Oct 10:19
· 88 commits to main since this release
Immutable release. Only release title and notes can be modified.
e375937

tak compare gating can now be configured per benchmark, with report-only benchmarks, an absolute instruction floor and named acceptances. The gate policy is now read from the base revision, and a comparison that compared nothing now fails. New commands and flags cover regressions that already landed on main (tak detect), history over time (tak log), local before/after measurement (tak run --baseline), per-function attribution (tak explain), building and measuring past commits (tak backfill --commits), and two kinds of extra metrics that are reported but never gate. tak is pre-v1: every new flag, key, report wording and file layout below may change. Read Breaking Changes before upgrading CI.

Highlights

  • Gating is more precise and harder to get around. Each benchmark can have its own gate, a specific regression can be accepted by name, and a pull request can no longer loosen its own gate by editing tak.toml.
  • More ways to read history. tak detect flags steps that reached main, tak log shows each series over time, and tak backfill --commits builds past commits so there is history to compare against.
  • More context next to instruction counts. Per-function profiles, custom metrics such as binary size, and DHAT heap-allocation counts are recorded and reported. Only instruction counts gate.

Added

Gating

  • Per-benchmark gates, report-only benchmarks and an instruction floor. A benchmark or subject can set its own gate table, which overrides [gate] key by key. A regression now has to exceed both pct and the new min_delta floor. The default floor is 0, so existing verdicts don't change. enabled = false makes a benchmark report-only: a rise past its threshold is marked (not gated) and never fails the run. The floor can also be set with --gate-min-delta / TAK_GATE_MIN_DELTA. A benchmark's own gate wins over --gate-pct. When any gate differs from [gate], the report adds a gate column and the verdict reads N benchmark(s) above their gate. Otherwise the report is byte-for-byte unchanged. tak now rejects invalid gate values (a negative, NaN or infinite pct, a negative or fractional min_delta, unknown keys) when it loads tak.toml. By @jdx in #158.

    [gate]
    pct = 1.0
    min_delta = 0
    
    [bench.startup]
    cmd = ["./target/release/mycli", "--version"]
    gate = { pct = 5.0, min_delta = 20000 }
    
    [bench.help]
    cmd = ["./target/release/mycli", "--help"]
    gate = { enabled = false }   # report only
  • Accept a regression in named benchmarks. tak compare --accept BENCH waives the gate for one exact benchmark name. It is repeatable, and every other benchmark still gates. Accepted rows are marked (accepted) and listed with their source. The CI guide shows how to drive the flag from a tak-accept:NAME label that only maintainers can apply. Tak-Accept: BENCH commit trailers in BASE..REV are honoured only when [gate] accept_trailers = true or TAK_ACCEPT_TRAILERS=1 is set. When the setting is off, the report lists any trailers it found and says they were ignored. Each trailer names exactly one benchmark using its whole value, commas included, so repeat the trailer to accept several. By @jdx in #153 and #164.

  • allow_empty setting. With [gate] allow_empty = true, TAK_ALLOW_EMPTY=1 or --allow-empty, an empty comparison passes with a warning on stderr instead of failing. Under GitHub Actions the warning is a ::warning:: annotation. Regressions still fail. --allow-empty is now a global flag, so it also works with tak run --baseline --gate. tak compare reads the setting from the base revision's tak.toml. With jdx/tak-action, also set fail-on-nothing-compared: false to warn instead of fail. By @jdx in #173.

New commands

  • tak detect checks for instruction-count regressions that already reached main. Run it after tak run --record and tak push. It walks REV's first-parent history (--window, default 20 recorded commits) and compares consecutive recorded points in each series:

    • It fails only on a step onto REV that exceeds that series' gate, so a main workflow fails once, on the push that introduced the step.
    • A step across unrecorded commits is shown as a git range.
    • Earlier steps and sustained drift are listed but don't fail.
    • It supports per-benchmark gates, --accept, trailers, --no-gate and --allow-empty. It fails when nothing was compared, including on a first recording.
    • It needs full history (fetch-depth: 0).

    By @jdx in #154.

    - name: Detect regressions that landed
      run: |
        set -o pipefail
        tak detect | tee -a "$GITHUB_STEP_SUMMARY"
  • tak log shows each benchmark's history over REV's first-parent commits. It prints one table per bench/tool/runner series, with the instruction-count Δ from the previous measurement and the wall time. -n (default 30) counts recorded commits. --bench filters, and an unknown name is an error. --html PATH writes a self-contained HTML report with SVG charts and no scripts or external assets. The CI guide includes a GitHub Pages example. tak history output is unchanged. By @jdx in #160 and #166.

  • tak explain and tak run --profile-dir show which functions an instruction-count change came from. --profile-dir DIR keeps the cachegrind profile from the run that gave the reported minimum, at DIR/<bench>/<subject>.cachegrind.out. tak explain BASE HEAD matches two such directories and lists the functions whose self cost changed most (--top N, default 10). It only reports and always exits 0. Functions are matched by name, and stripped binaries show up as ???. Profiles are not stored in notes, so the base profile has to come from measuring the base yourself. The new attribution guide describes two ways to set that up in CI. By @jdx in #157.

    tak run --bench startup --profile-dir base -- ./mycli hello
    # rebuild with the change
    tak run --bench startup --profile-dir head -- ./mycli hello
    tak explain base head

Measuring

  • Local baselines. tak run --save-baseline NAME saves a run's records to <git-common-dir>/tak/baselines/NAME.jsonl, which is never committed or pushed and is shared across worktrees. tak run --baseline NAME measures again and prints the tak compare table, without writing notes. Saving merges by series, so --bench a --save-baseline x updates only a. With --gate, the run exits non-zero on a regression past the benchmark's gate. It also fails when it can't check everything it was asked to: nothing ran, a count failed, a series is missing from the baseline or was saved only on another runner class, or a check failed. When everything measured is report-only, --gate passes and prints a note saying nothing was gated. An older tak refuses to save over a baseline that holds newer-schema records. By @jdx in #155 and #165.

    tak run --save-baseline before
    # edit, rebuild
    tak run --baseline before --gate
  • tak backfill --commits RANGE builds and measures past commits. Each first-parent commit, newest first, is checked out into a temporary detached worktree. tak runs the new [build] table there, measures the benchmarks from the current tak.toml, and appends the results to that commit's note, with the commit date as ts.

    • Subjects already recorded for the runner class are skipped. --force measures again, adding a second record.
    • --limit (default 20) caps builds per run, so rerunning continues where the last run stopped.
    • Build failures and per-benchmark measurement failures are remembered locally and passed over on later runs. --force, a [build] change, a runner-class change or (for measurement failures) any edit to tak.toml retries them. A failed instruction count records nothing for that benchmark.
    • --dry-run lists commits and builds nothing.
    • Programs and directories from the checkout must resolve inside it. tak checks them before and after each setup, prepare, sample, check and valgrind run.
    • On Unix, an interrupt kills only tak's own build and measured process groups, removes the worktrees and exits with the signal's status.

    Backfilled numbers are only comparable with CI's if they were built the same way. By @jdx in #159, #171 and #172.

    [build]
    cmd = ["cargo", "build", "--release", "--locked"]
    tak backfill --commits main~20..main --dry-run
    tak backfill --commits main~20..main
    tak push
  • Custom metrics. A metric.NAME table on a benchmark, subject or [defaults] records either a file's size in bytes (file) or the single non-negative number a command prints (cmd). Metrics appear in run output, --export-json and notes. tak compare shows them in a separate table and never gates on them. Names must match ^[a-z][a-z0-9_]*$. instructions, wall_* and alloc_* are reserved. A metric that can't be taken fails the run, and nothing is recorded. By @jdx in #156.

    [bench.startup.metric.binary_bytes]
    file = "target/release/mycli"
  • Heap allocations via valgrind DHAT. allocations = true (on a benchmark, subject or [defaults]) or tak run --allocations runs each subject three more times under DHAT. tak records the minimum alloc_blocks, alloc_bytes and alloc_peak_bytes. These appear in run output, --export-json and a separate tak compare table. They are reported only and never gate. Statically linked binaries and programs with their own allocator report 0, and tak warns about it. A DHAT failure produces a warning, and the rest of the measurement is still recorded. When the same benchmark appears on several runner classes, tak compare rows now name the runner. By @jdx in #161.

Fixed

  • Background processes no longer hang or spoof instruction counts. valgrind's summary is now read from its own log file instead of the subject's stderr. Before, a process the subject left running could hang counting until it exited, and output that looked like valgrind's summary could be read as the count. cachegrind's I refs: 0, which it reports when it can't write its output, is now treated as a failed count instead of being recorded as zero. By @jdx in #157 and #161.
  • Report tables escape | and backslashes in benchmark, tool and runner names, so a name containing | no longer shifts the columns in tak compare, tak run --baseline and tak detect. Control characters in names read from notes are printed as escapes such as \n in every report. By @jdx in #167 and #164.

Changed

  • The adoption guide now recommends jdx/tak-action on GitHub Actions. The manual pull-request workflow is fixed: its credential-removal step failed with actions/checkout v6 and later. By @jdx in #163 and #169.

Breaking Changes

  • tak compare fails when nothing was compared. A comparison where no series was measured on both sides now prints the report and then exits non-zero. This happens when the base was never recorded, notes weren't fetched, or the two sides ran on different runner classes. Before, it exited 0. Pass --allow-empty, or set [gate] allow_empty = true, where an empty comparison is expected, such as the first pull request after adopting tak or a runner-class change. --no-gate still never fails. The report's first line, **Nothing was compared…, is unchanged. Workflows that grep for it should anchor the pattern: grep -q '^\*\*Nothing was compared'. By @jdx in #162.

  • tak compare reads its gate policy from the base revision's tak.toml, from git, instead of the working tree. This covers [gate], per-benchmark gates, accept_trailers and allow_empty. A pull request that changes a gate is compared under the base's gate, and the change takes effect once it merges. The report adds a line saying so. Flags and environment variables still override the file.

    • The base commit and its tree must be in the clone. A missing base or a base tak.toml that doesn't parse is an error, and --no-gate doesn't waive it.
    • With no tak.toml at the base, built-in defaults apply.
    • To let a specific regression through on a pull request, use --accept instead of editing the gate.
    • tak detect and tak run --baseline still read the working tree.

    By @jdx in #168.

  • Control characters are rejected in names. tak.toml benchmark and subject names, --bench, the runner class and TAK_TOOL (where it becomes the recorded tool name) can no longer contain control characters, newlines included. Rename any that do. By @jdx in #164.

Full Changelog: v0.0.13...v0.0.14