Skip to content

Reduce repeated setup in expensive Rest tests - #10006

Merged
hua7450 merged 1 commit into
PolicyEngine:mainfrom
hua7450:reduce-rest-test-setup
Oct 8, 2026
Merged

hua7450 merged 1 commit into
PolicyEngine:mainfrom
hua7450:reduce-rest-test-setup

Conversation

@hua7450

@hua7450 hua7450 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Related to #9904.

What and why

The Rest tests repeat expensive setup for identical marginal-tax-rate scenarios and rebuild a baseline model already available to the federal-credit tests. Reuse copied, read-only results for each marginal-rate cap, and supply the existing module baseline to each independently constructed credit reform.

  • Marginal-rate coverage: 10 simulations become 7. Only output arrays are cached; each distinct cap and roommate scenario still has its own simulation and reform.
  • Federal-credit ordering: 3 explicit full baseline builds become 1. Each reform retains its own parameter tree and variable registry.
  • Preserve all 29 cases, their parameterizations, populations, years, assertions, and existing Rest process groups.

Local cost measurements

Test file / Rest group Full-process time, before → after Peak RSS, before → after
test_marginal_tax_rate_coverage.py / heavy-b 118.5 → 76.3 seconds 2.62 → 2.27 GiB
test_federal_credit_limit_order.py / remaining 134.3 → 96.0 seconds 3.12 → 3.32 GiB

Combined elapsed time fell from 252.8 to 172.4 seconds: 80.4 seconds saved (31.8%) for these two files. Memory was not uniformly lower: federal-credit peak RSS rose approximately 6.4% in this pair.

These are single before/after local measurements on macOS with Python 3.14.6, PolicyEngine Core 3.32.8, the frozen dependency lock, CI's itemization setting, and Hypothesis seed 20261007. Each file ran in a separate sequential process; timings include import, setup, and shutdown. Measurements used baseline a451dd5737f; the model, dependency versions, and affected test baselines are unchanged in current main c6a9b818350. Full Rest group memory and Linux CI savings remain unmeasured.

Test plan

  • Policy YAML coverage: not applicable; test setup changes only.
  • Both affected Python files: all 29 existing cases pass before and after, with identical collected case IDs.
  • Static comparison preserves test names, parameterization decorators, and assertion counts; reviewed the setup and calculation-order changes.
  • make format and git diff --check pass on the latest main base, which includes Skip the pull request workflow for draft PRs #9993.
  • Changelog fragment in changelog.d/.

axiom: n/a: test setup refactor only; no policy changes.

@hua7450
hua7450 marked this pull request as ready for review October 8, 2026 00:49
@hua7450
hua7450 merged commit 2ca9d3a into PolicyEngine:main Oct 8, 2026
48 checks passed
hua7450 added a commit to hua7450/policyengine-us that referenced this pull request Oct 8, 2026
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.

1 participant