Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The extract-phase test compared elapsed time with a 60-second limit and failed on macOS CI runners with nothing slower in the code (#1429). It now counts the calculate calls the extract phase makes for 51 and 204 records in the same states and requires the same number. TestBenchmark was already marked slow ("Run with: pytest -m slow"), but the marker was unregistered and nothing skipped it, so its absolute limits ran in every CI job. Register the marker and skip slow tests unless a -m expression is given. Fixes #1429 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
idtl 2 alone never requests staxbc or sctc, so a per-record loop in the Delaware staxbc path went unnoticed (two mutants passed). Alternate idtl 2 and 5, which together request every implemented output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
perf-tests-runner-independent
branch
from
October 12, 2026 01:04
574d649 to
ba9498b
Compare
Review of #1441: the old timed test ran standard output (idtl 0) and the call-count test ran only idtl 2 and 5, so a per-record path taken only when every record asks for standard output would go unnoticed (for example, computing marginal rates one household at a time). Run the count check in both output modes. Also: the CPS-like states are TAXSIM SOI numbers, not FIPS codes; the check is a fixed number of top-level calls, not one per output variable; and any -m expression, not only -m slow, turns off the slow skip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1429
Problem
test (macos-latest, 3.11)failed on wall-clock limits intests/test_performance.py, onmainand on unrelated PRs, with nothing slower in the code. Each failure listed in #1429 was the only one in its job. Onmain@ 2da4a45 (run 38101317049),TestBenchmark::test_benchmark_cps_liketook 266.3s against its 240s limit (1 failed, 501 passed, 8 skipped, 3 xfailed).versioningneedstest, soversioningandpublishwere skipped, and that merge's release waited for a later push (3.2.0,be55c81).Two tests compared elapsed time with a fixed number of seconds:
TestExtractResultsStructure::test_extract_builds_dataframe_without_row_loop:extract_time < 60.0for 200 records. Its docstring says it guards against a return to row-by-row extraction with redundantcalculatecalls (the pre-Vectorize PolicyEngineRunner for ~100x speedup #692 code).TestBenchmark(test_benchmark_500_records< 120s,test_benchmark_cps_like< 240s). The class was already marked@pytest.mark.slowwith the docstring "Run with: pytest -m slow", but nothing deselectedslowtests. Onmain,pyproject.tomlhas nomarkersandaddoptsis-ra -q, and there is notests/conftest.py. CI runspytest tests/, so both benchmarks ran in every job.Change (test-only; no file under
policyengine_taxsim/changes)PolicyEngineRunneron 51 households, one in each state, and on the same households repeated 4 times (204 records). It counts theMicrosimulation.calculatecalls made while_extract_vectorized_resultsruns, and requires the two counts to be equal and nonzero. Only top-level calls count: a PolicyEngine formula reads its inputs throughcalculatetoo, and how many of those happen depends on the households. The counter covers the main simulation, the rebate-free twin and the marginal-rate branch. The households alternate idtl 2 and 5. idtl 2 alone never requestsstaxbcorsctc, and idtl 5 alone never requestsaddmedorv44; together they request all 43 implemented outputs.slowtests are skipped unless asked for. The marker is registered inpyproject.toml. Atests/conftest.pyhook skipsslowtests unless a-mexpression is given, sopytest tests/(CI) skips the two benchmarks with a reason, andpytest -m slowruns them. With any-mexpression, pytest's own selection decides. Skipping is more visible than-m "not slow"inaddopts: a skip is reported with its reason, while a deselected test is silently not run, even when named by node id._make_cps_like_records, shared by the benchmark and the new test. It returns a frame identical to the old inline code forn=2000(pd.testing.assert_frame_equal, checked locally).CLAUDE.md.TestGeneratePhaseEfficiency::test_generate_does_not_scale_linearlykeeps its timing ratio with a floored denominator (#696, #1073). It is not in #1429's failure evidence, so it is left alone.The invariant the extract test checks: for a fixed set of households, the number of top-level
calculatecalls in the extract phase does not depend on how many records there are.Evidence
The new check still catches per-record work
Each mutant is a throwaway copy of
policyengine_taxsimfromorigin/main(git archive origin/main policyengine_taxsim | tar -x) with one edit. The test was run against each copy withPYTHONPATH=<copy> pytest tests/test_performance.py -k test_extract_builds_dataframe_without_row_loop. A plugin printed which copy was imported, to confirm the edit was the code under test.calculateper recordcalculateper record in the Delawarestaxbcpath (_apply_de_staxbc_elected_path, reached only at idtl 5)calculateper Delaware record onlycalculateper record on the marginal-rate branch simulationcalculateper record on the rebate-free twin (v40)The first version of this PR used idtl 2 only. M2 and M3 passed against it, because
staxbcis requested only at idtl 5. That is why the households now alternate idtl 2 and 5.Equal counts are exact, not approximate. A probe on
main@ 72fdc04 counted the same number of top-level calls for 20 and 200 records at idtl 0 (11 and 11), and for 51 and 255 records at idtl 2 (112 and 112). In the clean run, the 166 calls split as 160 on the main simulation, 4 on the rebate-free twin and 2 on the marginal-rate branch.CI on this branch (ba9498b)
All 12 checks pass. The extract test passed in all six test jobs, which cover policyengine-us 1.783.0 (Python 3.10) and 2.38.19 (Python 3.11) on macOS, Ubuntu and Windows. Each job reports
SKIPPED [2] tests/test_performance.py: wall-clock benchmark, skipped by default; run with pytest -m slow. On macOS 3.11 the skip list differs frommain@ 2da4a45's only by that line (8 skipped there, 10 here). macOS 3.11 summary:700 passed, 10 skipped, 3 xfailed in 4230.18s (1:10:30).Locally (
pytest 8.4.2, Python 3.11):pytest tests/test_performance.py -k TestBenchmark: 2 skipped, with the reason.pytest tests/test_performance.py::TestBenchmark::test_benchmark_cps_like: 1 skipped. A named benchmark is reported as skipped, not silently deselected.pytest tests/ --collect-only -m slow: 2 tests, both inTestBenchmark.pytest tests/test_performance.py --collect-only -m "not slow": 11 of 13.Cost
The new test runs the runner twice (51 and 204 records); the default run no longer runs the two benchmarks. CPU time per runner call, measured in one Python 3.11 process on the same machine (
time.process_time(), which a loaded host disturbs much less than wall time):test_benchmark_500_recordstest_benchmark_cps_like(2,000 records, idtl 2)Wall time on this host was not representative (load averages of 150 to 390 on 18 cores).
Not in this PR
versioningandpublishstill needtest; with these limits out of the default run, the failures in macOS 3.11 CI fails on wall-clock limits in test_performance.py (main and unrelated PRs) #1429 no longer occur.axiom: n/a: test-only change
🤖 Generated with Claude Code