Skip to content

Keeper object-based snapshots - #99651

Merged
kssenii merged 42 commits into
masterfrom
keeper-object-based-snapshots
Apr 1, 2026
Merged

kssenii merged 42 commits into
masterfrom
keeper-object-based-snapshots

Conversation

@kssenii

@kssenii kssenii commented Mar 16, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Implement object-based snapshot in keeper. Closes #95766. Added new setting snapshot_transfer_chunk_size, by default equal to 0. 0 means disabled: the whole snapshot is sent as a single NuRaft object. This value should be used until all keeper servers upgrade to version supporting object based snapshots to avoid issues during upgrade.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.485

@clickhouse-gh

clickhouse-gh Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [740b4a5]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_llvm_coverage, 4/5) failure
test_overcommit_tracker/test.py::test_user_overcommit FAIL cidb IGNORED
Stress test (arm_tsan) failure
Server died FAIL cidb IGNORED
Logical error: Shard number is greater than shard count: shard_num=A shard_count=B cluster=C (STID: 5066-457d) FAIL cidb, issue ISSUE CREATED
Stress test (arm_msan) failure
Server died FAIL cidb IGNORED
MemorySanitizer: use-of-uninitialized-value (STID: 2410-47e0) FAIL cidb, issue ISSUE EXISTS

AI Review

Summary

This PR adds chunked Keeper snapshot transfer (including remote-disk loader reuse), new profile events/settings, and extensive integration/gtest coverage. I reviewed all changed files plus current PR metadata. I did not find any new high-confidence blockers or major issues in the current HEAD diff beyond items already discussed earlier in the PR thread.

ClickHouse Rules
Item Status Notes
Deletion logging ✅
Serialization versioning ✅
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Mar 16, 2026
@kssenii
kssenii force-pushed the keeper-object-based-snapshots branch from d0a0a91 to 636b69e Compare March 16, 2026 21:39
Comment thread src/Coordination/KeeperStateMachine.cpp Resolved
Comment thread src/Coordination/KeeperStateMachine.cpp Resolved
Comment thread src/Coordination/KeeperStateMachine.cpp Resolved
@antonio2368 antonio2368 self-assigned this Mar 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 90.90% 90.90% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 65.66% (455/693) · Uncovered code

Full report · Diff report

@kssenii
kssenii added this pull request to the merge queue Apr 1, 2026
Merged via the queue into master with commit 8645c36 Apr 1, 2026
156 of 159 checks passed
@kssenii
kssenii deleted the keeper-object-based-snapshots branch April 1, 2026 11:40
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 1, 2026
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
The skill shipped with three correctness bugs that silently broke for
any PR set other than the original 33-PR validation:

1. `scripts/build_per_pr_metrics.py` carried a hardcoded
   `PR_MANUAL_VERDICT` dict (verdicts for 21 specific PRs) and prose
   referencing specific commits — wrong output for every other input.
   Deleted; the per-PR markdown matrix is now composed by Claude
   directly from `per_pr_metrics_long.tsv` using `PR_PERF_TABLE.md` as
   the structural template, which is what `SKILL.md` already said the
   workflow does.

2. `scripts/build_pr_branch_isolated.py` had hardcoded `PR_BRANCHES`
   and `PR_NAMES` dicts; the branch filter `if r["branch"] not in
   PR_BRANCHES.values()` produced an empty file for every other PR
   set. Rewritten to read `(pr, title, branch)` tuples from
   `pr_to_nightly.tsv` (which now carries the `branch` column), so it
   works for any PR list.

3. `THRESHOLD = 2026-03-25` was hardcoded in `build_pr_nightly_map.py`
   and `compute_deltas.py`, even though `rebuild.sh` already accepts a
   TS-filter argument. Both Python scripts now read
   `KEEPER_SKILL_THRESHOLD` from env (default `2026-03-25`);
   `rebuild.sh` exports it from `$2`.

Also dropped dead `pr_out_of_window.tsv` write (never consumed),
removed unused `import os` in `build_pr_nightly_map.py`, and updated
SKILL.md to drop the deleted script from Phase 3 and document the
`headRefName` requirement in `pr_meta.tsv`.

Smoke test: `cumulative_gains.tsv` md5 is byte-identical to the
pre-optimisation baseline; `pr_branch_isolated.tsv` for `ClickHouse#99651`
(`keeper-object-based-snapshots`) reproduces the canonical
validation point (5764 rps, 544.8 ms p99) end-to-end without any
hardcoded mappings.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
The PR-branch staging query had a `branch IN (<20 hardcoded names>)`
filter — same silent-failure mode that affected
`build_pr_branch_isolated.py`: any branch outside the original
33-PR validation set is dropped at the SQL layer, so the
pool-median baseline shrinks (or vanishes) for new analyses.

The data warehouse `keeper_stress_tests.keeper_metrics_ts` is
already scoped to keeper-stress runs, so `branch != 'master'`
plus the timestamp filter is sufficient to bound the result.

Smoke test for the original 33-PR window: branch pool grows
from 15 hardcoded → 49 actual branches; weekly pool size for
`ClickHouse#99651` rises from 10 → 26-28 runs (tighter weekly baseline).
The canonical validation point (5764 rps, 544.8 ms p99) still
reproduces.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
The widen-to-±1-week fallback in `build_pr_branch_isolated.py` did
week-number arithmetic on the formatted string:

    new_wk = f"{yr}-W{int(wn)+delta:02d}"

For a PR HEAD landing in W01 of any year, this produces `W00`
(invalid); for W52 in a 52-week year, it produces `W53` (invalid).
Neither key exists in the pool dict, so the widening silently
returns an empty list and the row is dropped without warning.

Replace with date arithmetic on the actual `datetime`, then format
the resulting iso-week — handles year and W52/W53 boundaries
naturally.

Also dropped a pointless `import_statistics()` wrapper around
`import statistics` and moved the import to module scope where it
belongs.

Smoke test: cumulative_gains.tsv byte-identical to baseline; the
canonical `ClickHouse#99651` validation point (5764 rps, 544.8 ms p99, pool
26-28 runs) reproduces unchanged.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
`build_pr_branch_isolated.py` excluded the PR HEAD row from the
weekly pool by filtering on `rps != head["rps_v"]`. Two distinct
PR-branch runs that happen to share the same rounded `rps` were
both filtered out, biasing the pool median.

The probability of a value collision rises with pool size — and
since we just dropped the hardcoded branch list (`5e2f9db2eea`),
pools now carry ~30 runs/scenario/week instead of ~10.

Carry `(sha8, run_ended)` through the pool tuples and exclude head
by that identity. The same-week filter and the ±1-week widening
filter both switch from value comparison to identity comparison.

Smoke test: the canonical `ClickHouse#99651` validation point still
reproduces (5764 rps / 544.8 ms p99); pool sizes for prod-mix
went from 26 to 27 (one extra row recovered that was previously
mistakenly dropped on rps collision); cumulative_gains.tsv md5
unchanged at `c03b62474b0dbaad218dffc8b7c43f07`.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
`05_container.sql` projects six container metrics (`peak_mem_gb`,
`avg_mem_gb`, `avg_cpu_cores`, `p95_cpu_cores`, `max_cpu_cores`),
but `load_container` in `build_metrics_table.py` only copied three
of them. The miss matters for `avg_mem_gb`, which is referenced as
a tracked metric in `build_cumulative_gains.py:31`
(`"avg_mem_gb": "↓"`).

Result: every cumulative-gains report silently produced zero
`avg_mem_gb` delta rows, even though the SQL had pulled the data
from `keeper_metrics_ts`. Verified post-fix: 62 `avg_mem_gb`
rows now appear in `cumulative_gains.tsv` for the 33-PR window.
The canonical `ClickHouse#99651` PR-branch isolation point still
reproduces unchanged (5764 rps / 544.8 ms p99) since it doesn't
touch container metrics.

`avg_cpu_cores` is added for symmetry — the SQL emits it; the
loader should populate it. No downstream consumer references it
yet, but loading it costs one line and avoids the same drift
the next time someone wires it up.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
`compute_deltas.classify` used uniform 5/15 thresholds for every
lower-better metric. The rubric in references/methodology.md
specifies wider bands for tail latency and memory because they
are documented as noisier than throughput:

    rps:                         clean ≥ −5%, watch −5..−15%, regression < −15%
    read_p99_ms / write_p99_ms:  clean ≤ +10%, watch +10..+30%, regression > +30%
    peak_mem_gb:                 clean ≤ +10%, watch +10..+30%, regression > +30%

The 5/15 code over-reports `watch` / `regression` verdicts on p99
and peak-mem in `per_pr_summary.tsv` compared to the documented
rubric.

Hoist the bands into a `CLASSIFY_BANDS` table indexed by metric
name, with `DEFAULT_BANDS = (5, 15)` as the fallback for metrics
not in the table. `classify` reads `(clean_band, watch_band)` from
the table and applies the same comparison as before.

`error_pct` already uses the documented absolute-PP bands at the
top of `classify` and is unchanged.

Smoke test: cumulative_gains.tsv md5 unchanged
(`e5a27e01008ef7e23597ee041f68103b`); ClickHouse#99651 isolation row
unchanged (5764 rps / 544.8 ms p99). Verdict counts on the 33-PR
window happen not to shift in this dataset because the worst
metric per PR is dominated by metrics still on the 5/15 default
bands (`FileSync_us_per_s_avg`, `OutstandingRequests_max`,
`StorageLockWait_us_per_s_avg`, etc.); the fix is still
correct — it only relaxes the bands the methodology documents
as noisier.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
`06_pr_branch.sql` filtered by `name='error_pct'`, but the bench
source schema in `keeper_metrics_ts` only emits `error_rate`
(raw 0..1 fraction); `error_pct` is the column **alias** the
canonical `01_bench_summary.sql` projects, not a source-metric
name. So `pr_branches.tsv` always carried `error_pct = 0`,
silently dropping all branch-side error signals from the
PR-branch isolation pipeline.

Switch to `name='error_rate'` to match `01_bench_summary.sql`
(the `*100` factor and the `error_pct` alias stay the same).

Smoke test: `pr_branches.tsv` now has 336 non-zero `error_pct`
rows for the 33-PR window (was 0 pre-fix). `cumulative_gains.tsv`
md5 unchanged (it doesn't depend on `pr_branches.tsv`); ClickHouse#99651
isolation row unchanged (the script keys on rps/p99, not
error_pct).

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
The script's docstring describes the weekly baseline as a median
"across ALL OTHER PR-branch runs", with the explicit goal that
"median across many PRs cancels noise". The same-week filter,
however, only excluded the exact head row by `(sha8, run_ended)`
— earlier commits on the head's own branch (later WIP commits in
the same week, prior commits, or revert-and-retry pushes) were
still pooled into the baseline.

Those rows are correlated with the PR's code change, so they
don't cancel out — they bias `pool_med` toward the PR-specific
effect, diluting the isolated Δ toward zero.

Carry `branch` in the pool tuple and exclude every row whose
`branch` matches the head's branch (which subsumes the
`head_id` exclusion). `pool_rps` / `pool_p99` extraction now
indexes by tuple position so future tuple shape changes are
localised.

Smoke test on the 33-PR window: `ClickHouse#99651` head (`5764` rps /
`544.8` ms p99) is unchanged; pool sizes drop by 2-3 entries
per scenario (`27 → 25` for prod-mix, `28 → 26` for read/write),
and `pool_med` shifts ≤ 0.05 %. cumulative_gains.tsv md5
unchanged at `e5a27e01008ef7e23597ee041f68103b`.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
`06_pr_branch.sql` (and the parallel `01_bench_summary.sql`) used:

    max(ts)                        AS run_ended,
    maxIf(value, name='rps')       AS rps,
    maxIf(value, name='read_p99_ms') ...

When the same `(branch, scenario, commit_sha)` was retried — CI
flake recovery, second-pass validation — `keeper_metrics_ts` carries
multiple `ts` values for that group. `max(ts)` picks the latest;
each `maxIf(value, name='X')` independently picks the maximum
metric value across all retries. The result mixes the latest
timestamp with peak-across-all-runs values.

The reviewer's example (`branch='hot'`,
`scenario='read-multi-no-fault[default]'`,
`commit_sha=0482c5cd...`): two runs at `2026-04-08 22:52:32`
(`rps=180948`) and `2026-04-09 03:39:27` (`rps=173578`). The query
emitted `run_ended=2026-04-09 03:39:33` paired with `rps=180948` —
a 4 % overstatement that biases `build_pr_branch_isolated.py`
toward better-than-latest values for any branch with retries.

Fix: replace `maxIf(value, name='X')` with
`argMaxIf(value, ts, name='X')` in both `06_pr_branch.sql` (5
metrics) and `01_bench_summary.sql` (21 metrics — the bug is
symmetric on master baselines for nightlies that get retried).
`argMaxIf` returns the `value` of the row with the maximum `ts`
within rows of the requested `name`. Since all summary metrics
from one bench run share the same `ts`, every metric column ends
up consistently sourced from the latest run.

Smoke test: the reviewer's concrete row now reports
`rps=173578` (the latest run's value); the canonical `ClickHouse#99651`
PR-branch isolation row is unchanged (5764 rps / 544.8 ms p99 —
that head sha had only one run, so no shift); cumulative_gains.tsv
md5 is unchanged at `e5a27e01008ef7e23597ee041f68103b` because no
master commit in the 33-PR window had retries.

Addresses review comment
ClickHouse#104118 (comment).
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Five scripts had duplicated definitions of the same small helpers,
which made fixes drift apart over the review cycle:

  - `to_float` / `parse_float` (identical bodies) appeared in
    `build_cumulative_gains.py`, `build_per_pr_metrics_tsv.py`,
    and `compute_deltas.py`.
  - The fault/no-fault classification
    `("-fault[" in s and "-no-fault[" not in s)` was inlined in
    `build_pr_nightly_map.py`, `build_per_pr_metrics_tsv.py`,
    and `compute_deltas.py`.
  - `iso_week`, `classify`, `CLASSIFY_BANDS`, `DEFAULT_BANDS`,
    `HEADLINE_METRICS`, and `HEADLINE_LOOKUP` were defined in
    individual scripts but are part of the methodology rubric and
    should have a single source of truth.

Move all of them into `scripts/_common.py` and `from _common import`
across the five callers. Also add `require_cols(reader, names)` —
a small helper used by later commits to validate SQL-derived TSV
headers at load time so a renamed column fails loudly instead of
silently producing empty downstream data.

Behavior unchanged: smoke test reproduces `cumulative_gains.tsv`
md5 `e5a27e01008ef7e23597ee041f68103b` and the canonical `ClickHouse#99651`
isolation row (`5764 / 170169 / 7582` rps; `544.8 / 10.7 / 904.6`
ms p99; pool sizes 25/26/26) bit-for-bit.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Six follow-on findings from a readability audit of the post-review
state. None change behavior on the canonical 33-PR window —
`cumulative_gains.tsv` md5 stays at `e5a27e01008ef7e23597ee041f68103b`
and `ClickHouse#99651` PR-branch isolation row is bit-identical — but each
removes a way the code could mislead a future reader:

1. `build_per_pr_metrics_tsv.py` module docstring promised columns
   `delta_pct, delta_pp` but the writer at line 50 emits
   `delta_abs, delta_pct`. Update the docstring to match the
   actual schema.
2. `compute_deltas.py` computed `sf_pre` then never used it —
   leftover dead code from a pre-merge-clean check that never
   landed. Remove and add a comment clarifying the per-PR check
   is post-merge by design (the global "across the window"
   check is documented separately in `SKILL.md` Phase 5).
3. `build_pr_branch_isolated.py` hardcoded a 3-scenario tuple
   (`prod-mix`, `read-multi`, `write-multi` no-fault `[default]`).
   Any new PR-branch scenario added to the framework would be
   silently absent from the output. Derive the scenario list from
   `pool.keys()` so the script picks up new scenarios for free.
4. `compute_deltas.py` "best improvement" ranking used undocumented
   ±5/±10 thresholds that didn't agree with `CLASSIFY_BANDS`.
   Read the per-metric clean-band edge from `CLASSIFY_BANDS`
   instead, so the presentation rule is consistent with the
   significance bands documented in `references/methodology.md`.
5. `build_cumulative_gains.py` silently skipped any
   `(scenario, backend)` pair with `< 2*WINDOW_SIZE` runs. The
   global "no scenarios had enough runs" message stayed, but the
   per-pair drop was invisible. Emit a per-pair stderr line
   listing each skipped pair and its run count.
6. `build_metrics_table.py` module docstring didn't list the five
   staging files or the join semantics ("bench summary is
   authoritative; container/prom/mntr update in place"). Expand
   the docstring so a new reader can trace the data flow without
   reading every loader.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Single-binary entrypoint with subcommands `merge`, `prmap`,
`deltas`, `prmetrics`, `prisol`, `cumulative`. Each dispatches to
the corresponding step module's `main()` (or, for `deltas`, runs
the two `compute_deltas.py` entrypoints in sequence).

Trade-off taken: kept the 6 step modules as importable and let
`keeper_stress.py` be a thin dispatcher, instead of inlining all
six step-bodies into one 700-line file. The per-step files each
have a focused docstring and ~150 lines of one-job code; merging
them would be a readability regression. The wrapper gives the
documented "single entrypoint" win without sacrificing the
per-step structure.

Updates:
- `scripts/rebuild.sh` invokes `python3 keeper_stress.py <subcmd>`
  in place of the individual `python3 <step>.py` calls.
- `SKILL.md` Phase 3 table now lists the subcommand form.

Smoke test: pipeline runs cleanly end-to-end, `cumulative_gains.tsv`
md5 unchanged at `e5a27e01008ef7e23597ee041f68103b`, `ClickHouse#99651`
PR-branch isolation row bit-identical.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Two related future-Claude friction points the audit caught:

1. The default `"2026-03-25"` literal was duplicated across
   `rebuild.sh`, `build_pr_nightly_map.py`, and `compute_deltas.py`.
   Bumping one without the others would silently make scripts
   disagree on which PRs are in-window. Hoist the parsed
   `THRESHOLD` `datetime` into `_common.py` so both Python scripts
   share one definition. The bash-side default in `rebuild.sh`
   stays as-is — it sets the env var, which is a separate
   contract Python only consumes.

2. `compute_pr_deltas` and `compute_nightly_summary` both opened
   PR-set artefacts (`pr_to_nightly.tsv` and `pr_meta.tsv`)
   unconditionally. Today the orchestrator wraps them in PR mode,
   but a future Claude (or any user) running
   `python3 keeper_stress.py deltas` directly without
   `pr_meta.tsv` hits `FileNotFoundError`. The script's name says
   "deltas", not "PR-set", so the missing file looks like a bug.

   Guard both functions:
   - `compute_pr_deltas`: skip cleanly with a stderr note when
     `pr_to_nightly.tsv` is absent.
   - `compute_nightly_summary`: read `pr_meta.tsv` only when it
     exists; emit nightlies with empty `prs_landed` cells when
     it's not (date-range-only mode).

Verified end-to-end: 33-PR smoke test still produces
`cumulative_gains.tsv` md5 `e5a27e01008ef7e23597ee041f68103b` and
unchanged `ClickHouse#99651` PR-branch isolation row; standalone
`keeper_stress.py deltas` without `pr_meta.tsv` now writes a
`per_nightly_summary.tsv` with 39 nightlies and empty `prs_landed`
instead of crashing; 18 unit tests still pass.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Closes a use-case gap previously declared "deferred": comparing
two arbitrary commit SHAs directly. The PR-set workflow already
handles pre/post for a merge boundary, but ad-hoc questions like
"compare 740b4a5 vs e02b59d" needed an awk one-liner that
re-derived the per-metric Δ formula every time.

`scripts/build_commit_diff.py` reads `merged_metrics.tsv`,
indexes by (8-char SHA, scenario, backend), and for each
(scenario, backend) shared by both SHAs emits one row per
HEADLINE_METRIC with `value_a`, `value_b`, `delta_abs`,
`delta_pct`, and a `verdict` from `_common.classify`. Output
`commit_diff.tsv` shape mirrors `per_pr_scenario_deltas.tsv` so
future Claude has one schema to learn.

Failure modes handled:
- Either SHA missing → exit non-zero with stderr listing nearby
  SHAs in the dataset.
- One SHA has scenarios the other doesn't → emit only the
  intersection; print stderr note about the asymmetric pairs.

`scripts/keeper_stress.py`: extend dispatch to accept argv[2:]
trailing args; new `diff` subcommand wraps `build_commit_diff.main`.

`SKILL.md` Phase 3: new "Two-commit Δ" row in the intent table.

Smoke test: `keeper_stress.py diff fdf46ee e02b59d` (the
canonical `ClickHouse#99651` pre/post boundary) emits 20 (scenario, backend)
pairs; `prod-mix-no-fault[default] / rps` shows `5067.3 → 4971.1`
(`-1.90 %`, `clean`), matching the existing `per_pr_scenario_deltas.tsv`
row for `ClickHouse#99651` exactly. Pipeline parity holds:
`cumulative_gains.tsv` md5 stays at `e5a27e01008ef7e23597ee041f68103b`.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Three independent silent-failure / lossy-output modes flagged in
review while the prior round was being pushed:

1. **`compute_deltas.py:291`** — `kind` collapsed to `"fault"`
   when *any* scenario in a nightly was a fault sweep, conflating
   single-kind nightlies with mixed nightlies. Today's schedule
   runs single-kind sweeps per commit (verified: 18 fault + 21
   no-fault, 0 mixed across the 33-PR window), but the field
   pretended to encode the kind union. Now emits one of
   `"fault"` / `"no-fault"` / `"mixed"` based on the actual set,
   so downstream consumers (e.g. kind-matched baseline picking
   in `build_per_pr_metrics_tsv`) won't be silently misled if
   the schedule ever changes.

2. **`build_cumulative_gains.py:148`** — early `return` when no
   `(scenario, backend)` had `>= 2*WINDOW_SIZE` runs left
   `cumulative_gains_summary.tsv` missing entirely. Inconsistent
   with the header-only-on-empty pattern used for
   `pr_to_nightly.tsv`, `per_pr_scenario_deltas.tsv`, and
   `per_nightly_summary.tsv`. Now writes a header-only file with
   the canonical column list whenever the result is empty;
   downstream consumers see one stable schema regardless of
   window size. Verified against `KEEPER_SKILL_THRESHOLD=2030-01-01`:
   file is written with one header line, no crash.

3. **`build_pr_branch_isolated.py:126`** — when a PR had a head
   value but no usable comparison pool (empty same-week pool, or
   widening produced nothing usable), the script `continue`d and
   silently dropped that `(PR, scenario)` from
   `pr_branch_isolated.tsv`. A PR could look cleaner than it was
   simply because the hard cases vanished. Now emits an explicit
   "no-baseline" row (head value present; `pool_med_*` /
   `iso_d_*` empty; `n_pool=0`) so summaries can treat the case
   as `no-baseline` rather than absent data.

Smoke-test parity preserved: `cumulative_gains.tsv` md5 stays at
`e5a27e01008ef7e23597ee041f68103b`; the canonical `ClickHouse#99651` row
is bit-identical (`5764 / 170169 / 7582` rps; `544.8 / 10.7 /
904.6` ms p99); 18 unit tests pass.

Addresses review comments
ClickHouse#104118 (comment) ,
ClickHouse#104118 (comment) ,
ClickHouse#104118 (comment) .
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Two reviewer comments on `182355c9595`:

1. **`compute_deltas.py:183`** — `compute_pr_deltas` assigned the
   PR's overall verdict by inspecting `scenario_verdicts`. When
   the PR's `pre_sha` and `post_sha` are both present but share
   no `(scenario, backend)` pair (e.g. partial scenario coverage
   on one side), `scenario_verdicts` was empty, the
   `regression`/`watch` checks didn't fire, and the `else` branch
   silently labeled the PR `clean`. That's a false negative —
   the case is `not-yet-tested`, not `clean`.

   Verified against the 33-PR window: 6 PRs flipped from
   `clean` (false negative) → `not-yet-tested` (correct).
   Regression count is unchanged at 15.

2. **`build_noise_stats.py:51`** — the value filter `v > 0`
   dropped legitimate zero observations. For `error_pct` the
   dominant value is exactly zero (healthy nightlies have no
   client-observed errors), so the filter was excluding the
   baseline and biasing stddev/p95 of `error_pct` upward —
   making a uniformly-stable metric look noisy.

   Switch to `v >= 0` for non-negative metrics; only `None`
   (parse failure / missing column) is dropped. `cv` is now
   emitted as empty string when median is exactly zero (the
   coefficient of variation is undefined against a zero base);
   stddev / p95 are unaffected. Verified `error_pct` rows now
   appear in `noise_stats.tsv` (62 rows across all
   (scenario, backend) pairs) with median `0.0000` and
   meaningful stddev / p95 reflecting the actual error
   distribution.

Smoke parity: `cumulative_gains.tsv` md5 unchanged at
`e5a27e01008ef7e23597ee041f68103b`; canonical `ClickHouse#99651` row
bit-identical; 18 unit tests pass.

Addresses review comments
ClickHouse#104118 (comment) ,
ClickHouse#104118 (comment) .
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Four findings from a critical re-read of the recently-added
scripts. None are bugs in the strict sense, but each makes the
code easier for a future reader (or a future Claude editing it)
to understand without re-deriving intent.

1. `build_commit_diff.py:50` — when a SHA isn't found, the error
   suggestion was `sorted(by_sha8.keys())[:8]` (alphabetically-first
   8 SHAs). For a typo like `fdf46xxx → fdf46ee`, the user got a
   list of `00..` / `01..` SHAs and had to spot the close match
   themselves. Switch to longest-common-prefix ranking via a small
   `_common_prefix` helper, so the actual close match floats to
   the top. Verified: `diff fdf46xxx zzzz0000` now suggests
   `fdf46ee1` first for the typo and falls back to alphabetical
   for the no-prefix-match input.

2. `build_commit_diff.py:60` — `delta_pct` had four distinct
   semantics (missing data, 0→0, 0→positive, normal) implemented
   correctly but unexplained. Add a 4-line comment so a future
   editor doesn't "fix" the 0→0 → "" branch into a 0.

3. `build_noise_stats.py:55` — `statistics.stdev(values) if
   len(values) >= 2 else 0.0` had a dead `else` branch, since
   the outer `if len(values) < MIN_RUNS: continue` already
   guaranteed `len(values) >= 3`. Drop the conditional and add a
   one-line comment naming the invariant.

4. `build_noise_stats.py:57` — `statistics.quantiles(values, n=20)[18]`
   is the 95th percentile, but a future reader had to know that
   `n=20` returns 19 cut points and that index 18 is the 95 % mark.
   Add a 3-line comment explaining the magic number and the
   `< 4` fallback to `max`.

No behavior change for any well-formed input. Smoke parity
preserved: `cumulative_gains.tsv` md5 unchanged at
`e5a27e01008ef7e23597ee041f68103b`; `ClickHouse#99651` row bit-identical;
18 unit tests pass.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Three independent findings from a fresh self-review:

1. **`PR_PERF_TABLE.md:3` referenced a deleted file.** The
   sample-output template said "_Companion to
   `PERFORMANCE_GAINS.md`_", but `PERFORMANCE_GAINS.md` was
   removed in the slim-down round (`3ab7611e82b`). A future
   Claude reading the canonical per-PR template would chase a
   dangling reference. Drop the parenthetical; the rest of the
   sentence stands on its own.

2. **`_common_prefix` was a private helper in `build_commit_diff.py`
   with no test coverage.** It's a generic 5-line longest-common-
   prefix function used to rank SHA-typo suggestions. Move it to
   `_common.py` (rename: drop the leading underscore — it's now
   part of the shared API surface), import it from
   `build_commit_diff`, and add 5 unittest cases covering
   no-overlap / partial-overlap / identical / one-is-prefix /
   empty-input edges. A regression here would silently degrade
   suggestion quality without raising. Test count: 18 → 23.

3. **`diff` and `noise` subcommands weren't mentioned in
   `rebuild.sh`.** They're on-demand by design (you don't run
   them every pipeline pass), but a reader scanning the
   orchestrator's bottom would miss the broader skill surface.
   Add a 4-line trailing comment listing the on-demand
   subcommands so the CLI surface is discoverable from
   `rebuild.sh` alone.

Smoke parity: `cumulative_gains.tsv` md5 unchanged at
`e5a27e01008ef7e23597ee041f68103b`; `ClickHouse#99651` row bit-identical;
all 23 unit tests pass; SHA-typo path still ranks `fdf46xxx`
suggestions with `fdf46ee1` first.
zlareb1 added a commit to zlareb1/ClickHouse that referenced this pull request May 6, 2026
Address review comment 3194583058: the date-range workflow promised
"between A and B" but only filtered ts >= '{{TS_FILTER}}', so a request
like "between 2026-04-01 and 2026-05-01" silently included every nightly
after 2026-05-01 and let cumulative deltas drift as new runs accumulated.

Add a parallel TS_FILTER_END / KEEPER_SKILL_THRESHOLD_END upper bound that
mirrors the existing lower bound at every layer:

  - All 6 staging SQL queries: append `AND ts < '{{TS_FILTER_END}}'`.
  - `rebuild.sh`: accept `$3` as the upper bound; sed-substitute both
    placeholders; export both env vars for the Python pipeline.
  - `_common.py`: parse `KEEPER_SKILL_THRESHOLD_END` (defaults to far-future
    sentinel `9999-12-31`) so unbounded callers keep today's behavior.
  - `build_pr_nightly_map.py` and `compute_deltas.py`: filter PRs against
    the half-open `[THRESHOLD, THRESHOLD_END)` interval.
  - `SKILL.md`: update Phase 2 invocation and Example 2 ("between
    2026-04-01 and 2026-05-01") to pass both bounds.
  - `tests/test_common.py`: 2 new cases for the `THRESHOLD_END` default
    and explicit-env-var parse path. 23 -> 25 cases, all pass.

Backward-compat regression contract: invoking `rebuild.sh ... 2026-03-25`
(no upper bound) still produces `cumulative_gains.tsv` md5
e5a27e01008ef7e23597ee041f68103b and the `ClickHouse#99651` PR-branch isolation row
bit-identical. Bounded smoke (`... 2026-03-25 2026-04-15`) verified to
produce strictly fewer rows in `bench_summary.tsv` and `merged_metrics.tsv`,
with max `run_ended` < `2026-04-15` and all `pr_to_nightly.tsv` `merged_at`
< `2026-04-15`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object-based snapshot in Keeper

4 participants