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
{{ message }}
Repository navigation
Test modules keep cached tax-benefit systems and simulations for the rest of the test run #2357
Five Python test modules cache tax-benefit systems or simulations in module-level functools.lru_caches that are never cleared, so everything they hold stays alive for the rest of the pytest worker's run:
one fresh CountryTaxBenefitSystem plus a reform per (parameter, value) drawn: up to 21
test_cliff_evaluated_properties.py
tax_benefit_system(mtr_adults), maxsize=None
4 reforms, each over its own fresh system
test_state_pension_age.py
differential_simulation(), situation_template()
a ~10,000-person simulation with every year it calculated, and a template simulation
test_state_pension_credit_qualifying_age.py
its own copy of differential_simulation() (pytest imports test_state_pension_age a second time under policyengine_uk.tests.), one_person_units_template()
as above
test_uc_work_related_groups_properties.py
qualifying_age_couples()
a simulation and the system it built
Each cached system also keeps the last simulation built on it alive: Simulation.__init__ sets tax_benefit_system.simulation = self.
On CI run 38165445604 (branch mem-measure/2331-run2b, per-worker memprobe artifacts), the worker that ran the two-child-limit file went from 1.10 to 1.65 GiB RSS during that file (13 systems built) and stayed there; malloc_trim after the module did not return it, because the cache still referenced the systems.
Goal: release this memory when each module finishes, and hold less while it runs, without changing which tests run or their outcomes.
Activity