Skip to content

Proofs 5x faster: Db2 database pool, active databases, batched CLP, per-estate cache - #4180

Merged
squid-protocol merged 1 commit into
mainfrom
perf/proof-speedups
Oct 2, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
perf/proof-speedups

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Proofs run about 5x faster. The comparison itself is unchanged: every proven case's report, coverage line and Db2 dump bytes are identical to main's.

Where the time went (measured)

  • Db2 connects took ~1.1 s each. Nothing held GGDB active, so every JDBC or CLI connect activated it and every last disconnect deactivated it. Each Java reset, dump and task transaction connects, so most of a Db2 case's time went here. Tested: with the database deactivated, connects took 1084–1109 ms; after ACTIVATE DATABASE, 2–3 ms.
  • CLP calls take ~1.1 s each, mostly the CLP back end starting. Setting up a case made one call per table drop, per table's columns and per table's identity column. The batch path also made 1 + 3 calls per table per run.
  • The global Db2 lock serialised all 17 Db2 cases.
  • Every case re-scanned and re-refactored its corpus (~12 s), though the result depends only on the corpus and the engine.

GnuCOBOL was never the bottleneck: about 7% of a case.

What changed

  1. A database pool instead of one global lock. Db2 cases run side by side on a pool of databases in the one Db2 instance: GGDB, GGDB1, … (GITGALAXY_DB2_POOL, default 4). Each case holds one database for its whole run, with a lock file per database. GGDB keeps the lock path older checkouts take, so a checkout without this change still never shares a database.
    • Why a database per case, not a schema per case: the programs name their schemas explicitly (CARDDEMO.TRANSACTION_TYPE, IBMUSER.ACCOUNT, GENASA1.*), and several cases share each schema. A schema per case would mean rewriting both sides' SQL. A database per case leaves every name as written, and databases share no catalog, rows or identity counters.
    • Pool databases match GGDB where results depend on it: each is created with GGDB's code set (UTF-8), territory (us), collation (IDENTITY) and page size (4K). Diffing the full db cfg against GGDB shows only self-tuned AUTOMATIC memory sizes, lock-list sizing and logging (GGDB archives its logs, the pool databases use circular logging). None of those changes what a query returns.
  2. Each database is held active (activate, once a process).
  3. Fewer CLP calls. Catalog metadata is read once a run in one query and cached. A run's reset is one CLP call and its dumps another. create() uses one call for the drops plus the 32K table space, and one for the DDL.
  4. equivalence_cache.py builds the corpus scan (CICS file facts) and the corpus refactor (the input to every generated project, det_port's estate included) once per key:
    • Key: the corpus commit plus git status --porcelain, every engine file's bytes, the Python version and the GITGALAXY_* environment.
    • Restore: a cached refactor is restored with its recorded absolute paths rewritten to the run's directory. If a binary file ever holds such a path, the cache falls back to a fresh refactor.
    • Checked on CBSA: a cached-then-restored clean room is byte-identical to a fresh one (162 files), once each run's own directory is normalised. The projects generated from them are identical (301 files) up to their own work-directory paths, which is also the only difference between two fresh runs.
    • Off switch: GITGALAXY_EQUIV_CACHE=off turns it off.

The Java-side CICS test template is unchanged. With the database active its connects cost ~2 ms, so changing it would only add risk.

Before / after (same machine)

run before (main) after
carddemo-acctupdate, --faults all 54 s 19 s (33 s cold cache)
cbsa-inqacc 130–231 s 16–21 s
genapp-lgicdb01 104–195 s 24 s
genapp-lgdpdb01 (8 tables) 83 s* 20 s
carddemo-cobtupdt (batch Db2) 92 s* 20 s
det sweep (proof_sweep.py --det-only) 45 min (--jobs 2) 8 min 32 s (--jobs 4), 8 min 27 s (--jobs 6)
model sweep (23 ports) 16 min 42 s* 12 min 4 s

* measured after I had activated GGDB by hand, so main's usual times are higher.

The 130–231 s spread is the same case run more than once; my first run competed with another agent's Db2 work. --jobs 6 gains nothing over --jobs 4, so 4 (the pool size) is the setting to use.

Correctness gate

  • Det sweep: "as expected": 48/50 proven, the two KNOWN_UNPROVEN cases the only ones not proven. All 50 cases' verdicts and coverage lines match the main sweep's: 705 scenarios before, 705 after.
  • Model sweep: 23/23 proven.
  • Reports and dumps: report.json identical old vs new, paths aside, for carddemo-acctupdate, cbsa-inqacc, genapp-lgicdb01, genapp-lgdpdb01 and carddemo-cobtupdt. Raw dump files are byte-identical (lgdpdb01: 146 files; cobtupdt: 13).
  • Tests: new tests/cobol_mainframe/test_equivalence_speed.py (9 tests: pool selection, connection strings, one catalog read, dump splitting, cache restore equals fresh, binary-path fallback, cache key, off). The existing harness tests pass: 155 passed, 8 skipped. tests/ruff_audit.py --ci: no new findings.

Docs: the det-port SKILL.md environment and command timings, and det_port_design.md's Db2 section.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

…s held active, batched CLP calls, per-estate cache

- equivalence_db2: a pool of databases in the one Db2 instance (GGDB, GGDB1 ..; GITGALAXY_DB2_POOL, default 4),
  one case a database for its whole run (a lock file each; GGDB keeps the lock path older checkouts take). Every
  schema-qualified name in either side's SQL stays as written; databases share no catalog, rows or identity
  counters. A pool database is created as GGDB is (code set, territory, collation, page size).
- Each database is held active: an inactive one is activated by every connect (~1.1 s) -- which most of a Db2
  case's time went to (each reset, dump and task transaction connects).
- Catalog metadata read once a run in one query; a run's reset and dumps one CLP call each (~1.1 s a call).
- equivalence_cache: the corpus scan and the corpus refactor every case starts from, built once per key (corpus
  commit and state, every engine file, GITGALAXY_* env) and restored with recorded paths rewritten; a binary file
  holding a path falls back to a fresh refactor.

Det sweep 45 min -> 8.5 min, 48/50 proven as expected, every case's coverage line identical (705 scenarios).

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

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 3cdbb79 into main Oct 2, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the perf/proof-speedups branch October 2, 2026 22:12
squid-protocol added a commit that referenced this pull request Oct 3, 2026
…1 (model-written, unedited, proven) (#4187)

Ports only, split from #4168; the loop fixes are #4186. Each is the porting
loop's answer on attempt 1 (claude-sonnet-5-5, no tools, ticket prompt only),
unedited, with provenance.json. Re-proven on main after #4178/#4180:
  cbsa-updacc      10 scenarios, 7/7 paragraphs, 5/6 branches
  genapp-lgicdb01  12 scenarios, 3/4 paragraphs, 4/12 branches
  genapp-lgapvs01   8 scenarios, 2/3 paragraphs, 5/9 branches


Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants