You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reduce //cdk:test wall time by eliminating repeated full-stack synthesis in the handful of mega-suites that dominate the CDK Jest suite. Profiling (see #365) shows the cost is concentrated: the top 5 suites are 362s of 437s suite-time (83%), and the single heaviest file is 135.6s. Each new App() + Template.fromStack() is ~27s; several suites synthesize the same stack multiple times where one shared synth would do.
This is the predecessor to sharding (#365) — lowering the per-file floor is both a bigger, simpler win on its own AND what makes sharding worthwhile later. Parent: #363.
Evidence (8-core local, coverage on)
Suite
Time
Full synths in file
Notes
test/stacks/github-tags.test.ts
135.6s
4 (synthWithTags)
2 hoisted to beforeAll, 2 still inline (empty string, compute_type ecs tests)
test/constructs/task-api.test.ts
83.5s
12 (4 beforeAll + inline)
audit which inline synths can share a template
test/stacks/agent.test.ts
50.2s
2
already mostly beforeAll; verify
test/constructs/task-orchestrator.test.ts
49.9s
2
already mostly beforeAll; verify
test/bootstrap/synth-coverage.test.ts
44.4s
2
by-design coverage synth; check if reducible
Approach
For each heavy suite: synthesize each distinct stack configuration exactly once (in beforeAll), and have individual tests assert against the cached Template. Only synth again when a test genuinely needs a different context/config. Do not weaken assertions or merge tests — only remove redundant synthesis.
Concrete first target — github-tags.test.ts: hoist the two remaining inline synthWithTags(...) calls (empty string values and compute_type: 'ecs') into shared beforeAll templates keyed by their context, reused across tests. Est. ~−54s on this file alone.
Acceptance criteria
Each targeted suite synthesizes each distinct stack config at most once; redundant inline synths removed.
All tests still pass (2177 CDK tests) with identical assertions; coverage thresholds unchanged and met.
//cdk:test wall-time improvement reported on real 4-core CI (before/after); target: meaningfully below the current ~298s, driven by the top-5 suites.
No reduction in what is asserted; no test merged away to fake a speedup.
mise run build clean; no drift; no new flakiness.
Notes for implementer
new App() + Template.fromStack() is the expensive operation (~27s here) — cdk-nag aspects run during synth. Counting these per file is the quickest way to find waste: grep -cE "new App\(|Template.fromStack" <file>.
Some suites already use beforeAll correctly — verify before changing; the win is only in the files that synth the same config repeatedly.
Summary
Reduce
//cdk:testwall time by eliminating repeated full-stack synthesis in the handful of mega-suites that dominate the CDK Jest suite. Profiling (see #365) shows the cost is concentrated: the top 5 suites are 362s of 437s suite-time (83%), and the single heaviest file is 135.6s. Eachnew App()+Template.fromStack()is ~27s; several suites synthesize the same stack multiple times where one shared synth would do.This is the predecessor to sharding (#365) — lowering the per-file floor is both a bigger, simpler win on its own AND what makes sharding worthwhile later. Parent: #363.
Evidence (8-core local, coverage on)
test/stacks/github-tags.test.tssynthWithTags)beforeAll, 2 still inline (empty string,compute_type ecstests)test/constructs/task-api.test.tsbeforeAll+ inline)test/stacks/agent.test.tsbeforeAll; verifytest/constructs/task-orchestrator.test.tsbeforeAll; verifytest/bootstrap/synth-coverage.test.tsApproach
For each heavy suite: synthesize each distinct stack configuration exactly once (in
beforeAll), and have individual tests assert against the cachedTemplate. Only synth again when a test genuinely needs a different context/config. Do not weaken assertions or merge tests — only remove redundant synthesis.Concrete first target —
github-tags.test.ts: hoist the two remaining inlinesynthWithTags(...)calls (empty string valuesandcompute_type: 'ecs') into sharedbeforeAlltemplates keyed by their context, reused across tests. Est. ~−54s on this file alone.Acceptance criteria
//cdk:testwall-time improvement reported on real 4-core CI (before/after); target: meaningfully below the current ~298s, driven by the top-5 suites.mise run buildclean; no drift; no new flakiness.Notes for implementer
new App()+Template.fromStack()is the expensive operation (~27s here) — cdk-nag aspects run during synth. Counting these per file is the quickest way to find waste:grep -cE "new App\(|Template.fromStack" <file>.beforeAllcorrectly — verify before changing; the win is only in the files that synth the same config repeatedly.References
docs/design/CI_BUILD_PERFORMANCE.md(PR docs(design): CI build performance roadmap + implementer notes (#363) #364)🤖 Generated with Claude Code