Repository navigation
Weight most integration tests so shards actually balance by duration - #115963
alexey-milovidov merged 1 commit into
Conversation
get_optimal_test_batch LPT-balances integration test shards using TEST_DURATIONS. A suite absent from that table contributes weight 0, and a prefix group where every file is absent is placed by blind round-robin (idx = i % total_batches) with no weight accounting at all. Both the parallel and the sequential path do this. The table's own regeneration query, embedded above it in this file, ended HAVING dur > 60000. That floor kept only 297 of 1085 discovered test files (27.4%), while the discarded suites carry 19.8% of the total wall-clock mass. So the LPT pass balanced roughly a quarter of the suite and the rest landed blind: measured per-shard spread 20.2%, with the peak shard sitting at 85% of its 7200s parallel budget. Ordinary run-to-run dilation (about 1.15x on timed-out runs) then tips it over, xdist raises session-timeout, and the job reports ERROR with zero failing tests. That has happened 27 times across 27 distinct pull requests and 5 of the 6 old-analyzer shards in 30 days. Lower the floor to 1000ms and regenerate the table with it: 302 -> 1079 entries, coverage 27.4% -> 98.4%, sequential-path coverage 1/5 -> 5/5 files. Both hunks ship together deliberately. Refreshing the data while leaving the floor in place would mean the next person following the documented regeneration instruction silently reverts the fix, and would leave the comment contradicting the data below it. No logic changes. The table only decides which shard a test lands on, never whether it runs, and the function's own total_assigned == len(tests) check still holds. Validated offline against the real get_optimal_test_batch, with the table trained on days 8-21 and scored on the last 7 days so the windows are disjoint: parallel peak 6087s -> 5568s (-8.5%), spread 20.2% -> 2.2%. Dropping the floor is the load-bearing half; refreshing alone reaches only 9.8%. Headroom before the peak shard breaches 7200s goes from x1.18 to x1.30. One shared table drives every integration family, so all six with available ground truth were scored at their real batch counts and all improve on spread, none regressing. Alternatives rejected on measurement rather than preference: raising session_timeout_parallel (uncensored per-worker demand is p99 6165-6832s, already inside the budget, so the budget is not the constraint), file-count imputation for zero-weight groups (0.1% effect, since module cost is heavy-tailed), per-family duration tables (Spearman rho 0.964-0.971 between families, and LPT needs only relative ordering), and resharding 6 -> 8 (reverted by a maintainer in e1b6984, and unnecessary once the peak is 77% of budget). Two known limitations. The table is a snapshot and drifts as tests change; a scheduled refresh, or the deliberately-disabled dynamic path, is the durable answer and is an owner call. The Batches parallel weights debug print still excludes round-robin groups, left alone here to keep this change to its cause.
Internal second-model review (click to expand)An independent cold review of this diff plus a second-model gate pass. The gate returned no
Independently reproduced, not taken from the implementation's notes: the two-hunk provenance Also confirmed by reading, not asserted: both call sites read the same table with no One limitation worth stating plainly: this diff changes no test file, so its own integration Session id: cron:clickhouse-review-slot-49:20260822-235400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-49:20260822-235400 |
|
Workflow [PR], commit [76d9303] Summary: ✅ AI ReviewSummaryThis PR lowers the regeneration floor for Final Verdict✅ No blocking issues found. |
|
cc @leshikus, could you review this? The integration shard balancer's weight table was regenerated by a query ending |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline. |
CI finish ledger - 76d9303No failures. 174 jobs, The 163 skips are scoping rather than lost signal: each carries a self-describing reason Session id: cron:our-pr-ci-monitor:20260823-023000 |
2bd35e9
|
This change left a residual that I do not think I should pick a fix for on my own, so here is what I measured.
What this PR did and did not do. Coverage went from 27.4% to over 99% of measured wall-clock mass, and that part holds: the packer now prices the six shards to within 1.3% of each other. What it did not do is make the price correct. Measured on that tree, the priced spread is 3.5% and the real spread is 24.7%: shards 1 to 4 carry 17108 to 18538 test-seconds, shard 5 carries 21761. One model fits all five arms, Why shard 5. Eight multi-node cluster-starting suites moved onto it from four different origins, and their cost there inflated 1.5x to 6.8x with identical test counts, so this is not staleness or added tests. The inflation is ordered by how startup-dominated a suite is: a 1-test cluster suite goes 25 s to 167 s, while a 96-test work-dominated suite does not move at all. That is the mechanism you described in It is not the memory-thrash shape: that node stalls 1.71 s, 0% of runtime, against 72% and 80% on the hung jobs, so The part that decides the fix. I tried the input-side levers first and both fail by measurement, because LPT equalises the priced weight by construction, so changing its inputs gives a different set of modules at the same price rather than a lighter worst shard.
So the levers that deterministically reduce the worst shard both cost something I should not spend for you:
I would not revert this PR: that restores a table that hid 19.4% of the measured mass, and the residual is the contention term the coverage work exposed rather than a regression in it. Tell me which of the two you want and I will send it. If you would rather fold it into what you already have open, that works too and I will leave it alone. One observation I am not filing: on the two trees with real test failures, a replacement |
|
A second, independent symptom of the same overcommit, measured today, because it bears on the choice above.
What the kernel records at the four kills in that job, from the
Total anon 40.2 GiB against the 40.78 GiB So this shard is over its container budget in the same way it is over its session budget, and I do not think I should choose between the levers on my own:
I will implement whichever you prefer. My own preference is the 7th batch, because it is the only one that moves the memory and the wall-clock at the same time. |
`Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6)` reported `Timeout` on master with `xdist.dsession.Interrupted: session-timeout: 7200.0 sec exceeded` after `974 passed, 10 skipped ... in 7360.29s`. Nothing failed and nothing hung - the longest quiet gap in the whole run was 136 s - the batch simply held more work than the two-hour pytest `--session-timeout` allows, and was cut off with 20 of its 1004 modules still to go. This is chronic rather than a one-off. Over the last three weeks the six old-analyzer batches reported `Timeout` 133 times between them, on every one of the six. The job is required on every pull request, on master and on backport branches, so each occurrence is a red required check on an unrelated change. The cause is capacity, not balance. The integration suite measures about 112000 test-seconds; six batches of three xdist workers can absorb at most 129600, so the packing runs at 86% of the budget on average and the heaviest shard lands at 119.7 of the 120 available minutes. Scoring `get_optimal_test_batch` over the 1139 modules actually in `tests/integration/`, weighted by per-module `sum(test_duration_ms)` measured on the failing commit itself, reproduces the failure exactly: batch 5 of 6 - the batch that timed out - is the heaviest, at 100% of budget. At eight batches the heaviest shard is 82 minutes, 68% of the budget, and the measured spread across shards narrows from 1.24 to 1.09. Batches are the right lever rather than a longer timeout. Aggregate compute is unchanged, because the work is the same and only the parallelism differs, so the only cost is one more per-batch setup (about 3 minutes) - and the job returns its answer 25% sooner than it does today. Both ASan flavors move together. `integration_test_asan_master_jobs` (`amd_asan_ubsan, db disk`, release branches) runs the same suite with the same worker count against the same budget and sits at the same 96-103 minutes per shard, so the measurement that rules out six for one rules it out for the other; it has simply had far fewer runs in which to show it since ClickHouse#116591 took it from four to six. The shared count now lives in `ASAN_IT_NUM_BATCHES` so the two cannot drift apart. `CORE_BLOCKING_JOB_NAMES` selects these jobs by substring, so the blocking gate picks up all eight batches with no change. While measuring this: `TEST_DURATIONS` in `ci/jobs/scripts/integration_tests_configs.py` sums to about 97000 test-seconds against a measured 112000, so the packer reports every shard as evenly packed (printing weights of `[5384, 5384, 5384, 5384, 5384, 5383]` for a run whose real shards ranged over 97 to 120 minutes). Refreshing that table is separate periodic maintenance - it is documented as such, and it repacks every integration flavor at once - so it is left for its own change. Eight batches hold with the table as it is. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=417aa9966eed1467f418da9b4deae15ef020c5f3&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%205%2F6%29 Related: ClickHouse#116591 Related: ClickHouse#115963 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
get_optimal_test_batchLPT-balances integration test shards usingTEST_DURATIONS. Asuite with no entry there gets weight 0 and is placed by blind whole-prefix round-robin with
no weight accounting, on both the parallel and the sequential path.
The table's own regeneration query, embedded above it in this file, ends
HAVING dur > 60000. That floor kept only 297 of the 1085 discovered test files (27.4%),and the discarded suites carry 19.4% of the total wall-clock mass. So a fifth of the cost is
invisible to the packer by design, the LPT pass balances a quarter of the suite, and the
unluckiest shard runs out of budget:
Integration tests (amd_asan_ubsan, db disk, old analyzer, N/6)has reportedsession-timeout occurred during test executionwith zerofailing tests 28 times across 28 distinct pull requests and 5 of the 6 shards in 30 days.
This lowers the floor to
> 1000and regenerates the table with it: 302 -> 1079 entries,99.3% of discovered files covered, and 7 prefix groups left on the blind round-robin path
instead of 620. Both hunks ship together on purpose - refreshing the data while leaving the
floor would mean the next person following the documented instruction silently reverts the
fix.
No logic changes. The table only decides which shard a test lands on, never whether it
runs; the function's own
total_assigned == len(tests)check still holds.Validated offline against the real
get_optimal_test_batch(below). This PR changes no testfile, so its own integration jobs skip by design and cannot validate it either way.
Caveats: the table is a snapshot and drifts (a scheduled refresh is the durable answer, and
an owner call), and the debug
Batches parallel weights:line still excludes round-robingroups - left alone to keep this diff to its cause.
Simulation: peak -9%, spread 20.2% -> 1.2%, 5 of 6 families improve
Real
get_optimal_test_batch, real file list, both phases modelled separately (parallel-n 3, sequential-n 1), batch counts fromjob_configs.py. Rows 1-3 are trained on days8-21 and scored on the last 7 days, so those windows are disjoint.
Dropping the floor is the load-bearing half. Headroom before the peak shard breaches 7200s:
x1.18 -> x1.30, against the ~1.15x dilation measured on timed-out runs. The last row's
window overlaps the scoring window, so it is an upper bound; row 3 is the honest oracle.
One shared table drives every family, so all six were scored against their own 7-day medians
using the table in this diff:
Five improve on both peak and spread. The release-only 4-way is the exception (+37s peak,
+2pp spread); it sits 12% over budget in both arms, so it is a capacity problem tracked
by #112261 rather than a balance one.
Controls, all firing: costing the fixed packing with a deliberately wrong model (every suite
1s) moves the spread 1.2% -> 22.4%; the current arm reproduces a large spread (per-shard
5164/6107/5507/6121/5492/4886); no test is lost or duplicated (1085 assigned, 1085 unique);
packing twice is byte-identical.
Workflow [PR]
Sync PR [sync-upstream/pr/115963]
Version info
26.9.1.299(included in26.9and later)