perf: --cycles N repeats once-per-life numbers (startup, shutdown, long-note open) per run #1149

Open
kayg wants to merge 3 commits from perf/single-shot-repeats into dev
Owner

Why

Startup, the first page, the first search, the long-note open and shutdown are measured once per server life. In a perf turn each of those cells gets one number per arm per round, so a 5–10 % change hides in the noise. On #1117 under the #1130 comparator, 11 such cells couldn't be resolved below 10 % (1k cold.startup, 1k shutdown, 10k open.long_note with a 34 % noise floor, …).

What this adds

  • calternal-perf --cycles N: each warm run becomes N short server lives on the indexed Home instead of the warm scenarios. Each life records one sample of:
    • cycle.startup (spawn until /healthz),
    • cycle.first_page,
    • cycle.long_note_file (the first open of each long note in this Home, read from its file) or cycle.long_note (later opens, rebuilt from history),
    • cycle.first_query,
    • cycle.shutdown (SIGTERM until exit), after an untimed wait until the Home scan and search catch-up are done.
  • So a run reports a p50 over N samples, and perf/compare.py (#1130) treats these as distribution cells, not single values.
  • cold.startup is repeated with the existing --cold-runs N.
  • idle::settle is split out of idle::quiet (same waits, no recording), so cycle lives reuse it. Normal runs are unchanged.

Finding behind the long-note split: the warm open.long_note takes long note run mod count. At 10k there are 5 long notes, so runs 0–4 open from the file and later runs rebuild from history. One cell mixes two code paths, which likely explains its 34 % noise. Cycle mode keeps them apart.

Not in this PR

No change to budgets or to the default warm run. perf/vm/paired-turn.sh (#1130) already passes extra flags after --, and its pre-flight finds --cycles in --help.

Gates

Run on dev-01: cargo build --release -p calternal-perf, cargo fmt --all -- --check, cargo clippy -p calternal-perf --all-targets -D warnings, cargo test -p calternal-perf. Results go in a comment.

🤖 Generated with Claude Code

## Why Startup, the first page, the first search, the long-note open and shutdown are measured **once per server life**. In a perf turn each of those cells gets one number per arm per round, so a 5–10 % change hides in the noise. On #1117 under the #1130 comparator, 11 such cells couldn't be resolved below 10 % (1k `cold.startup`, 1k `shutdown`, 10k `open.long_note` with a 34 % noise floor, …). ## What this adds - `calternal-perf --cycles N`: each warm run becomes **N short server lives** on the indexed Home instead of the warm scenarios. Each life records one sample of: - `cycle.startup` (spawn until `/healthz`), - `cycle.first_page`, - `cycle.long_note_file` (the first open of each long note in this Home, read from its file) or `cycle.long_note` (later opens, rebuilt from history), - `cycle.first_query`, - `cycle.shutdown` (SIGTERM until exit), after an untimed wait until the Home scan and search catch-up are done. - So a run reports a p50 over N samples, and `perf/compare.py` (#1130) treats these as distribution cells, not single values. - `cold.startup` is repeated with the existing `--cold-runs N`. - `idle::settle` is split out of `idle::quiet` (same waits, no recording), so cycle lives reuse it. Normal runs are unchanged. **Finding behind the long-note split:** the warm `open.long_note` takes long note `run mod count`. At 10k there are 5 long notes, so runs 0–4 open from the file and later runs rebuild from history. One cell mixes two code paths, which likely explains its 34 % noise. Cycle mode keeps them apart. ## Not in this PR No change to budgets or to the default warm run. `perf/vm/paired-turn.sh` (#1130) already passes extra flags after `--`, and its pre-flight finds `--cycles` in `--help`. ## Gates Run on dev-01: `cargo build --release -p calternal-perf`, `cargo fmt --all -- --check`, `cargo clippy -p calternal-perf --all-targets -D warnings`, `cargo test -p calternal-perf`. Results go in a comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Startup, first page, first search, long-note open and shutdown are
measured once per server life, so a perf turn gives one number per arm
per round and small changes hide in the noise (#1117). Cycle mode runs N
short lives per warm run instead of the scenarios, one sample each, and
keeps first (file) long-note opens apart from history rebuilds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
style(perf): rustfmt the settle split
Some checks failed
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
4dfdfbd6f2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Gates, head 4dfdfbd6f (dev-01, through ~/bin/slot, inside nix develop)

Gate Command Result
build cargo build -j4 --release --locked -p calternal-perf exit 0, sha256 aab31e87…498b
fmt cargo fmt --all -- --check exit 0 (the first run caught one line in idle.rs, fixed in 4dfdfbd6f)
clippy cargo clippy -p calternal-perf --all-targets --locked -j4 -- -D warnings exit 0
tests cargo test -p calternal-perf --locked -j4 9 passed, including the new parses_cycle_mode_and_defaults_to_off

Functional smoke (dev-01; a correctness check, not a measurement): calternal-perf --bin <#1117 cand> --sizes 1k,10k --runs 2 --cycles 4 --cold-runs 2 --idle-secs 0 --soak-secs 0. It took 33 s including fixture generation, with no failures.

  • Every cycle.* metric has 4 samples per run.
  • cycle.long_note_file appears once at 1k (one long note) and in run 1 at 10k (five long notes). Later opens are cycle.long_note.

Used next for the #1117 single-shot re-gate (turn p1117-cycles on perf-01).

### Gates, head `4dfdfbd6f` (dev-01, through `~/bin/slot`, inside `nix develop`) | Gate | Command | Result | |---|---|---| | build | `cargo build -j4 --release --locked -p calternal-perf` | exit 0, sha256 `aab31e87…498b` | | fmt | `cargo fmt --all -- --check` | exit 0 (the first run caught one line in `idle.rs`, fixed in `4dfdfbd6f`) | | clippy | `cargo clippy -p calternal-perf --all-targets --locked -j4 -- -D warnings` | exit 0 | | tests | `cargo test -p calternal-perf --locked -j4` | 9 passed, including the new `parses_cycle_mode_and_defaults_to_off` | **Functional smoke** (dev-01; a correctness check, not a measurement): `calternal-perf --bin <#1117 cand> --sizes 1k,10k --runs 2 --cycles 4 --cold-runs 2 --idle-secs 0 --soak-secs 0`. It took 33 s including fixture generation, with no failures. - Every `cycle.*` metric has 4 samples per run. - `cycle.long_note_file` appears once at 1k (one long note) and in run 1 at 10k (five long notes). Later opens are `cycle.long_note`. Used next for the #1117 single-shot re-gate (turn `p1117-cycles` on perf-01).
Author
Owner

271671e23: shutdown measured to 1 ms (was 20 ms steps)

The first #1117 cycle turn (18 rounds, perf-01) left 1k cycle.shutdown p50 unresolved (MDE 14 %). Its p95 ratio sat at exactly 1.000 (MDE 0.2 %). The cause: terminate checked for the server's exit every 20 ms, so a ~40 ms shutdown flipped between two 20 ms steps. It now checks every 1 ms. This affects only how precisely shutdown and cycle.shutdown are measured. The ms values are comparable with older runs only to within the old 20 ms step.

Gates on dev-01 (~/bin/slot nix develop -c …): cargo build --release -p calternal-perf, cargo fmt --all -- --check, cargo clippy -p calternal-perf --all-targets -D warnings and cargo test -p calternal-perf all pass (exit 0). Harness sha256 b19e2852….

Not merging; for the orchestrator.

### `271671e23`: `shutdown` measured to 1 ms (was 20 ms steps) The first #1117 cycle turn (18 rounds, perf-01) left 1k `cycle.shutdown` p50 unresolved (MDE 14 %). Its p95 ratio sat at exactly 1.000 (MDE 0.2 %). The cause: `terminate` checked for the server's exit every 20 ms, so a ~40 ms shutdown flipped between two 20 ms steps. It now checks every 1 ms. This affects only how precisely `shutdown` and `cycle.shutdown` are measured. The ms values are comparable with older runs only to within the old 20 ms step. Gates on dev-01 (`~/bin/slot nix develop -c …`): `cargo build --release -p calternal-perf`, `cargo fmt --all -- --check`, `cargo clippy -p calternal-perf --all-targets -D warnings` and `cargo test -p calternal-perf` all pass (exit 0). Harness sha256 `b19e2852…`. Not merging; for the orchestrator.
Author
Owner

2f8f4a9ce: --cycles N now adds lives after the warm scenarios; --cycles-only gives the old behaviour

What changed. --cycles N now runs N short server lives after each warm run, instead of replacing the warm scenarios. So one calternal-perf run per arm covers the warm cells and the once-per-life cells, which a full perf turn needs.

  • Long notes opened by the warm runs count as already opened, so cycle lives still tell a first (file) open from a history rebuild.
  • --cycles-only skips the warm scenarios, which was the earlier behaviour.

Gates. Run on dev-01 on the build tree perf/p1117-final-harness 75806caf2, which is #1117's perf crate plus every #1149 commit: cargo build --release -p calternal-perf, cargo fmt --all -- --check, cargo clippy -p calternal-perf --all-targets -D warnings and cargo test -p calternal-perf all exit 0.

Use. That harness ran #1117's final turns: 3 tickets on perf-01, 1k/10k/100k with --hot-only --cycles 4, in both layouts. Results are on #1117.

Merge note. This PR targets dev, which doesn't have --hot-only yet (that comes with #1117). If #1117 lands first, the rebase conflicts in args.rs and main.rs are trivial: keep both flags.

Not merging.

### `2f8f4a9ce`: `--cycles N` now adds lives after the warm scenarios; `--cycles-only` gives the old behaviour **What changed.** `--cycles N` now runs N short server lives *after* each warm run, instead of replacing the warm scenarios. So one `calternal-perf` run per arm covers the warm cells and the once-per-life cells, which a full perf turn needs. - Long notes opened by the warm runs count as already opened, so cycle lives still tell a first (file) open from a history rebuild. - `--cycles-only` skips the warm scenarios, which was the earlier behaviour. **Gates.** Run on dev-01 on the build tree `perf/p1117-final-harness` `75806caf2`, which is #1117's perf crate plus every #1149 commit: `cargo build --release -p calternal-perf`, `cargo fmt --all -- --check`, `cargo clippy -p calternal-perf --all-targets -D warnings` and `cargo test -p calternal-perf` all exit 0. **Use.** That harness ran #1117's final turns: 3 tickets on perf-01, 1k/10k/100k with `--hot-only --cycles 4`, in both layouts. Results are on #1117. **Merge note.** This PR targets dev, which doesn't have `--hot-only` yet (that comes with #1117). If #1117 lands first, the rebase conflicts in `args.rs` and `main.rs` are trivial: keep both flags. Not merging.
Some checks failed
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'perf/single-shot-repeats:perf/single-shot-repeats'
git switch 'perf/single-shot-repeats'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'dev'
git merge --no-ff 'perf/single-shot-repeats'
git switch 'perf/single-shot-repeats'
git rebase 'dev'
git switch 'dev'
git merge --ff-only 'perf/single-shot-repeats'
git switch 'perf/single-shot-repeats'
git rebase 'dev'
git switch 'dev'
git merge --no-ff 'perf/single-shot-repeats'
git switch 'dev'
git merge --squash 'perf/single-shot-repeats'
git switch 'dev'
git merge --ff-only 'perf/single-shot-repeats'
git switch 'dev'
git merge 'perf/single-shot-repeats'
git push origin 'dev'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!1149
No description provided.