Skip to content

tests: Mainframe Ground Truth's evidence, galaxy IR and javac-driven tests 2-4x faster - #5914

Merged
squid-protocol merged 2 commits into
mainfrom
ci/mgt-evidence-galaxy-ir
Oct 21, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
ci/mgt-evidence-galaxy-ir

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Mainframe Ground Truth is about 17% of the saturated CI pool's runner time. This PR speeds up three of its slow areas. The CI shares below come from run 39658216459's per-test times, 2,983 test-seconds in all.

area CI share here, before → after how
test_evidence_components.py 225 s (7.5%) 61.5 s → 18.2 s one file read once; only the input checked is computed; memoised regex helpers
test_galaxy_ir.py 236 s (7.9%) 50.9 s → 12.6 s tests/tools/scan_server.py: the engine imported once a process
38 files that run javac about 394 s (13%) 93 s → 50 s through tests/tools/javac_server.py (#5901)

1. test_evidence_components.py

test_the_components_partition_each_input (112 s on a runner) makes about 1,000 single-file edits. For each one it re-read every file from disk and recomputed all five inputs, only to compare one.

  • The test: it reads each file once (_read) and asks for only the input it checks, through the new names= argument to evidence.spec_inputs.
  • evidence.py: _java_code is memoised. _names answers from the port text's word set: a stem made of word characters is named exactly when it is one of the text's \w+ runs, and any other stem keeps the regex.
  • Same answers: compute_inputs is byte-identical to main's for all 52 evidence targets.

2. test_galaxy_ir.py

Its 32 galaxyscope scans of 2–3-file fixtures each spent about 1.3 s (about 3.5 s on a runner) importing the engine, for about 0.2 s of actual scanning.

tests/tools/scan_server.py provides galaxy_ir.scan_to_db with the same signature, but the engine is imported once per process:

  • How it scans: a single-threaded server forks a child per scan. The child runs the module exactly as python -m gitgalaxy.galaxyscope does (runpy, with the caller's environment and working directory).
  • No state carried over: every child starts from the same just-imported state, because the server never scans itself.
  • Same output: the master database is identical to the engine's own scan, every table and row (tested).
  • Fallbacks: no fork (Windows), GITGALAXY_SCAN_SERVER=0, or a failed server all go to galaxy_ir.scan_to_db itself.
  • No test body changes: the test file only rebinds scan_to_db.

4. The javac-driven tests

  • The conversion: 54 javac launcher calls in 38 files of tests/cobol_mainframe now go through javac_server.javac, imported as javac_run. Only the callee changed; argv and keywords are as they were.
  • The UTF-8 guard (test_java_subprocess_utf8.py) treats javac_run(...) as a javac launch, so the -encoding UTF-8 check still covers those calls.
  • Fix to javac_server:
    • The launcher's symlinks are now resolved before choosing its JDK. /usr/bin/javac and /usr/bin/java can be two different JDKs (17 and 21 on the box where this was found), so test_td_forge_5168's /usr/bin/javac had been compiled by JDK 21. A regression test covers it.
    • A bare javac from PATH is left to the launcher.

Checks

  • All 3,976 tests across the touched files and tests/tools pass (511 skipped).
  • New tests/tools/test_scan_server.py and additions to tests/tools/test_javac_server.py.
  • tests/ruff_audit.py --ci: no new findings.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits October 21, 2026 16:42
…inframe Ground Truth)

The two were 225 + 236 of Mainframe Ground Truth's 2,983 test-seconds (run 39658216459).

- test_evidence_components (61 s -> 18 s here): test_the_components_partition_each_input
  (112 s on a runner) re-read every file from disk and recomputed all five inputs for
  each of ~1,000 single-file edits, to compare one. The test now reads each file once
  (_read) and asks evidence.spec_inputs for the input it checks (`names=`, new);
  evidence.py memoises _java_code and answers _names from the port text's word set
  (a stem of word characters is named exactly when it is one of the text's \w+ runs;
  any other stem keeps the regex). compute_inputs is identical to before for all 52
  targets.
- test_galaxy_ir (51 s -> 13 s here): its 32 galaxyscope scans of 2-3 file fixtures
  each paid ~1.3 s (~3.5 s on a runner) of importing the engine for ~0.2 s of scanning.
  tests/tools/scan_server.py is galaxy_ir.scan_to_db with the engine imported once a
  process: a single-threaded server forks a child per scan that runs the module as
  `python -m gitgalaxy.galaxyscope` does (runpy, the caller's env and cwd), every child
  from the same just-imported state. Master DB identical to the engine's own scan,
  every table and row (tested). No fork, GITGALAXY_SCAN_SERVER=0, or a failed server:
  galaxy_ir.scan_to_db itself. The test file rebinds scan_to_db; no test body changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…und Truth)

The javac launcher calls (absolute path, as test_java_subprocess_utf8 identifies them)
in 38 files of tests/cobol_mainframe -- 54 calls -- go through javac_server.javac,
imported as javac_run; only the callee changes, the argv and keywords are as they
were. Those files, here: 93 s -> 50 s (1,710 passed, 452 skipped, both ways).

- test_java_subprocess_utf8: a javac_run(...) call is a javac launch (the -encoding
  UTF-8 check covers it as it covered the subprocess.run).
- javac_server: the launcher's links are resolved before its JDK is chosen. /usr/bin/javac
  and /usr/bin/java can be two JDKs (17 and 21 here): test_td_forge_5168's /usr/bin/javac
  got JDK 21's compiler, rc 2. A bare `javac` (PATH's) is the launcher's, not served.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 21, 2026
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol
squid-protocol enabled auto-merge (squash) October 21, 2026 21:30
@squid-protocol

Copy link
Copy Markdown
Owner Author

No description provided.

@squid-protocol
squid-protocol merged commit 7f98fd0 into main Oct 21, 2026
26 checks passed
@squid-protocol
squid-protocol deleted the ci/mgt-evidence-galaxy-ir branch October 21, 2026 21:45
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