Skip to content

Det Sweep: Db2 shards restore the pinned Db2's first start instead of repeating it (Part of #5882) - #5950

Merged
squid-protocol merged 1 commit into
mainfrom
perf/5882-db2-snapshot
Oct 22, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
perf/5882-db2-snapshot

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #5882 (CI speed).

Problem: on 10-21, 220 Db2 shard jobs used 57.5 runner-h, about half of Det Sweep. Each started the pinned Db2 image from scratch: instance setup, then a CREATE DATABASE for each pool database, one at a time. In run 39696713590 the first database was ready after 135-180 s and all of them after 302-440 s. The ~200-270 s of setup per shard is ~25% of that run's job time.

What it does:

  • New tests/tools/db2_snapshot.py (key | save | restore), modelled on db2_image_cache.py.
    • save starts a fresh container of the pinned image (never one a case has used, which would carry its tables) and creates GGDB..GGDB3 exactly as equivalence_db2 does. It then stops Db2 cleanly and keeps two tars: the container's changes over the pinned image (docker diff: ~400 paths, ~40 MB, no deletions, tarred as root so owners are kept) and the /database volume.
    • restore makes the container equivalence_db2 runs, from the pinned image, with that volume and delta, and starts it. equivalence_db2 then waits for it as for any container. No snapshot, another key, another image, or any failure: it leaves nothing behind and Db2 starts as before.
  • equivalence_db2.run_args(): the container's options in one list, so the restored container is the started one plus -v <volume>:/database. Pinned by a test.
  • det-sweep.yml db2 job:
  • The shard timing row gains db2_snapshot (true restored / false fell back / null not tried).

Checked, locally by hand (own container names; the shared gitgalaxy-db2 untouched):

  • fresh: GGDB + 3 pool databases in 146 s here
  • save 179 s
  • restore: equivalence_db2._ensure_container() ready after 33 s, and all 4 pool databases took a create / insert / query by 38 s
  • Restored databases keep GGDB's code set and territory.
  • Tests: 597 passed across the 20 test files touching the Db2 harness, the timing tool and the workflow; new test_db2_snapshot (3).

Expected on CI: all pool databases in roughly 50-70 s instead of 302-440 s, so ~3-6 min less per Db2 shard. That's ~10 runner-h/day at 10-21 volumes, and Db2 shards start proving sooner.

Owner check: this is still the real, digest-pinned Db2 (the standing "real Db2" decision). The databases are the same empty databases made by the same commands; they are just made once per key instead of once per shard.

To seed after merge: a workflow_dispatch of Det Sweep on main, or the next nightly (04:41 UTC), makes the entry. Until then every shard falls back to today's start.

🤖 Generated with Claude Code

…of repeating it (Part of #5882)

Each Db2 shard started the pinned image from scratch: instance setup, then one CREATE
DATABASE after another for its pool (run 39696713590: first database after 135-180 s,
all after 302-440 s; 220 Db2 shard jobs on 10-21). tests/tools/db2_snapshot.py keeps
that first start: the container's changes over the pinned image (docker diff, ~40 MB,
no deletions) and its /database volume (the instance, GGDB..GGDB3 empty), keyed by the
image digest and equivalence_db2.py. A shard restores it onto the pinned image before
the prewarm (equivalence_db2.run_args: the same container, plus the volume); a miss or
a failed restore starts Db2 as before. Main saves it, one shard, as the image (#5262),
from a FRESH container, never one a case has used.

Local, by hand: save 179 s; restore -> equivalence_db2 ready after 33 s, all four pool
databases took a create/insert/query by 38 s (fresh: 146 s here). The timing row gains
db2_snapshot (restored / fell back / not tried).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01E977ZMkfHVAsLSWrDLDaW5
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 22, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol

Copy link
Copy Markdown
Owner Author

PR #5950 @ dd9dfa6: 1 failed check(s)

== shepherd (label event) (failure) -- real
https://github.com/squid-protocol/gitgalaxy/actions/runs/39781535641/job/119833754560
repro: python tests/tools/pr_gates.py --fast
errors:
fail-on-cache-miss: false
##[error]Process completed with exit code 1.
log tail:
##[group]Run actions/cache@55cc834
with:
path: flake-cache
key: flake-history-39781535641
restore-keys: flake-history-
enableCrossOsArchive: false
fail-on-cache-miss: false
lookup-only: false
##[endgroup]
Cache hit for restore-key: flake-history-39774747153
Received 1000 of 1000 (100.0%), 0.0 MBs/sec
Cache Size: ~0 MB (1000 B)
[command]/usr/bin/tar -xf /home/runner/work/_temp/88c9d9f1-ac34-498e-aa7a-181715941a74/cache.tzst -P -C /home/runner/work/gitgalaxy/gitgalaxy --use-compress-program unzstd
Cache restored successfully
Cache restored from key: flake-history-39774747153
##[group]Run python3 tests/tools/shepherd_gh.py event --event-path "$GITHUB_EVENT_PATH" --flake-cache flake-cache/flake_history.json
python3 tests/tools/shepherd_gh.py event --event-path "$GITHUB_EVENT_PATH" --flake-cache flake-cache/flake_history.json
shell: /usr/bin/bash -e {0}
env:
GH_TOKEN: ***
##[endgroup]
#5950 approval marker for dd9dfa6: ok
#5950 auto-merge on: FAILED: GraphQL: refusing to allow a Personal Access Token to create or update workflow .github/workflows/det-sweep.yml without workflow scope (mergePullRequest)
##[error]Process completed with exit code 1.
Post job cleanup.
[command]/usr/bin/git version
git version 2.55.0
Temporarily overriding HOME='/home/runner/work/_temp/233099aa-04f0-4c90-b045-4d799de355c1' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]/usr/bin/git config --global --add safe.directory /home/runner/work/gitgalaxy/gitgalaxy
Removing SSH command configuration
[command]/usr/bin/git config --local --name-only --get-regexp core.sshCommand
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
Removing HTTP extra header
[command]/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader
[command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
Removing includeIf entries pointing to credentials config files
[command]/usr/bin/git config --local --name-only --get-regexp ^includeIf.gitdir:
[command]/usr/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
Cleaning up orphan processes

@squid-protocol squid-protocol added shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md and removed shepherd:needs-fix Bot: a real failure on this head; see the digest comment. Guide: docs/ci.md labels Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant