Repository navigation
Conversation
Raise the cycle collector's first threshold while this module copies policy trees, and run each pinned copy case for all three wage levels in one three-household simulation, replacing three derandomized generated examples that re-ran pinned paths at other wages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expected responses come from a new one-household reform simulation per wage level, as before; the three are shared with the fully-calculated clone test, so the three-household pins add no reference runs. State the GC fixture's measured effect, and why only the pins run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-measurement-copies
MaxGhenis
marked this pull request as ready for review
October 24, 2026 02:08
Review (GPT-6.1 Sol) found that the old derandomized example (clone after measuring a lone 20,000 household, then 50,000) was the only source whose measured response was zero for every household; every three-household source has nonzero households. Pin it again as a fifth example, with the source's wages a parameter once more (a tuple). The fixture docstring now states only saved measurements: 6.4 million tracked objects per tree copy, none garbage after it; 29 against 8 full collections; and the CI effect on the tests this change does not otherwise touch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been 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.
Cuts the CI time of
policyengine_us/tests/core/test_behavioral_response_measurement_copies.py(#9913) and keeps every case it ran. Only that test file and a changelog fragment change.Before this PR, the file took 1,512 s of the Rest
coregroup's 43:46 in main's push run 40031737740; the group took 11:51 on 2026-10-08 (run 38141803955), before the file existed. Since #10439 the file runs in a process of its own (core-2): 1,399 s of test time and 24:13 elapsed in #10439's PR run 40038526568, and 1,523 s and 26:22 in main's release run 40050303812.Where the time went
The file builds no
Microsimulation: every test uses one-person California households. The time goes to copying policy.clone_spm_systemdeep-copies the whole parameter tree: once per reform simulation built, twice per measurement (the reform branch withclone_system=True, and_baseline_measurement_branch) and once perclone().Parameter.clone(323,037 calls) took 23.1 s cumulative, including 16.4 s inParameterAtInstant.clone(3.77 million calls).metadata(copy.deepcopy(self.metadata)), andParameter.clonealso clones each of its values.copy.deepcopytook 21.4 s over 15 million calls.test_a_copy_reports_the_response_for_its_inputs_and_measurement_statetook 597 of the 1,512 s (run 40031737740). Undermax_examples=3, derandomize=Trueit ran four explicit pins plus three generated examples. With this test's old strategies, Hypothesis 6.168.3 and CPython 3.14, those three were the same on every run. Each example builds a reform simulation, makes up to two measurements and makes one copy.The
[None]/[reform1]and[entity]/[period]parametrizations each exercise a distinct construction path, so they stay:[None]/[reform1]: a simulation with and without a baseline;[entity]/[period]: a holder dropped for its entity or for its period.Changes
gc.freeze(), with the same threshold) was 6.8% faster again in two paired local runs (415 s against 445 s). It is left out for that gain: it takes every object alive when the module starts, from whichever modules ran before it in the process, out of collection until teardown.phases=[Phase.explicit]). Four of the five pins build their source as one simulation of three households, at 20,000, 50,000 and 100,000.(50,000, 100,000, 20,000), so each household moves to another's level.fresh_responseconcatenates them). A branch made after measuring is compared, as d1021 requires, with the source's measured responses scaled by its wages, and with a snapshot of the source's measurements.phasesmakes Hypothesis generate examples from the new strategies, not the old ones: three households in one source, with the copy's wages a permutation of theirs.The test now builds 8 reform simulations, makes 10 measurements and makes 3 clones, against 10, 12 and 4 before, counting the one-household references it builds and measures.
Coverage of each removed or merged case
Each pin keeps its
kindandafter_source_measured. The old pins at 50,000 are household 2 of the new ones:The pins also run five household cases the old test never ran:
Mutation check
A pytest plugin patches the code before the tests import it. It re-introduced the three defects the module docstring says #9913 fixed, the first in a representative form (see below), and one break of invariant 3. Every old case and every new pin ran one by one under each (local runs of the four-pin version):
_baseline_measurement_branchreturnsget_branch("baseline"))test_copies_own_their_measurementsandtest_a_branch_measures_a_new_period_without_touching_its_parent, both unchanged, fail under it.clone_system=Truebranch underget_branch("baseline").Pending, held while the host is reserved for another run (results to follow here):
Timings
CI, this file in its own process (
core-2), per-test JUnit times: two before runs, then this PR at the four-pin head 3037f63 (run 40052943537) and at the five-pin head 2ce982c (run 40089604888).test_a_copy_reports_the_response_for_its_inputs_and_measurement_stateLocal, four-pin version: full pytest totals and process wall times. Each process ran its tests serially, all four concurrently on a shared 18-CPU host under load 25 to 35:
gc.freeze()variant 415.2 and 415.3 s. Compare rows only within one table.Invariants
The file's four invariants (module docstring) and the tests that check them are unchanged. Only the Hypothesis test changes: which households one pinned run covers, plus the restored lone-household pin.
Shards
#10439 plans the Rest shards from the JUnit reports of recent successful release runs on main. The first release run after this merges records the file's new times, and plans made after that run use them. No Makefile change.
Review: GPT-6.1 Sol (Subfleet, hard tier) requested changes at 3037f63: the lone zero-response source, unsaved figures, and wording. This revision answers them; the re-review follows once the pending runs are in.
axiom: n/a: test-only CI cost change.
🤖 Generated with Claude Code