Repository navigation
ci(backend): Copy per-worker Snuba databases instead of bootstrapping each - #131172
sentry-junior[bot] wants to merge 1 commit into
Conversation
… each Backend shards spend about 80 CPU-seconds of ClickHouse during setup, on a 4-core runner that is already pegged, running `snuba bootstrap` five times (snuba-snuba-1 plus one per xdist worker). Almost all of that is ~420 ALTERs of wide tables per database. Bootstrap only default_gw0 and copy it to the other workers with BACKUP ... TO Memory / RESTORE ... AS, which rewrites database references in materialized views and Merge tables. The copies are identical to a bootstrapped database, schema and migration state, and take under a second. If the copy fails, fall back to bootstrapping each worker. Also load a CI ClickHouse profile (no query log, processor profiles or query/memory profiler) and logger level before any per-worker Snuba connects, so it reaches Snuba's sessions, unlike #129369. A new step prints query_log rows per database to show it. The resource monitor now takes `--phase NAME` and attributes samples to phases exactly (setup, snuba-bootstrap, tests), so ClickHouse CPU can be split between setup and the test run. Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
|
Results from run 43539870699 (all 30 shards passed, full suite with PR backend shards run on Arm, and every shard here and in the baselines got the same CPU (
Across the 30 shards, that's about 8 runner-minutes and 32 ClickHouse CPU-minutes saved per full run.
Open follow-ups, not in this PR:
|
Most of ClickHouse's CPU on a backend shard goes to setup. Phase 1 of
bootstrap-snuba.pyrunssnuba bootstrap --forcefive times at once: snuba-snuba-1'sdefault, plusdefault_gw0..3. Each one is ~700 DDL statements, mostly ALTERs of wide tables. On master x64 shard 21, ClickHouse used 80 of its 129 CPU-s in that ~37s window, about 2.2 of the runner's 4 cores, while the machine was pegged.default_gw0, then runsBACKUP DATABASE ... TO MemoryandRESTORE ... AS default_gwNfor the other workers. RESTORE rewrites the database in materialized views and in theMergetable. The copies match a bootstrapped database (SHOW CREATEfor every table plusmigrations_local) and take under a second. If the copy fails, it falls back to bootstrapping each worker. Locally this cut ClickHouse CPU for the bootstrap from 54 to 11 CPU-s.users.dprofile turns offlog_queries, processor profiles, and the query and memory profilers, and the logger level drops fromtracetowarning. Both reload without a restart. Profile settings only apply when a session starts, and [experiment] ci(backend): stop ClickHouse logging every test query #129369 loaded them too late. A newClickHouse queries loggedstep prints query_log rows per database, anddefault_gw*should be empty.monitor-resources.py --phase NAMEto set the phase. The sampler takes a sample as soon as the phase changes, and the summary'scpu_s_by_phasesplits CPU by phase:setup,snuba-bootstrap,tests.Before/after CI numbers, normalized by runner CPU model, are in a comment below.
Open questions:
default, which no test uses (~13–16 CPU-s). Turning off the server-level system logs (metric_log,asynchronous_metric_log, ...) needs a ClickHouse restart and saves only ~2–3 CPU-s per shard.via @joshuarli.
--
View Session [Sentry]