Every new system compiles its variable files again, which sys.monitoring coverage retains
维护者通常 2 天内回复
评估
调研方向
Start with TaxBenefitSystem.add_variables_from_file and coverage/sysmon.py to trace how variable files are compiled and how SysMonitor.code_objects retains code objects. The issue proposes compiling each file once per process and executing it in each system's own module; check that modules, classes, functions, and globals remain separate. Done means repeated system creation no longer accumulates code objects under sys.monitoring; the issue links pull request #608, which is already open.
由索引模型根据 Issue 内容生成。
描述
TaxBenefitSystem.add_variables_from_file compiles each variable file again for every new system (spec.loader.exec_module), so every system gets new code objects for the same source.
Coverage's sys.monitoring core keeps every code object it has seen alive until the process exits, so that it can key its records by id(code) (SysMonitor.code_objects in coverage/sysmon.py). It is coverage's default on Python 3.14, and opt-in on 3.12 and 3.13 with COVERAGE_CORE=sysmon. Under it, every system a process builds is retained as code objects, whatever happens to the system.
Measured on policyengine-uk (Python 3.13, coverage 7.16.2, core 3.33.2), one property-test file run serially: each Simulation left about 2,500 code objects and 3.6 MB of traced heap behind; with the C tracer or no coverage, memory stayed flat. On CI this grew four pytest-xdist workers to 15.3 of a runner's 15.6 GiB (PolicyEngine/policyengine-uk#2330).
A file's code object doesn't depend on the system that runs it. Compiling each file once per process and running that code object in each system's own module keeps every system's modules, classes, functions and globals separate, and removes the retention. It also saves the unmarshalling: building a UK system took 0.180 s of CPU instead of 0.289 s (median of 8, no coverage).
This is separate from #520 (the modules left in sys.modules), which this doesn't change.
- 主要语言
- Python
- 星标
- 22
- 派生
- 30
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 25
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PolicyEngine/policyengine-core 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
PolicyEngine/policyengine-core#605 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
PolicyEngine/policyengine-core#549 ·
维护者通常 2 天内回复
-
`restore_simulation` silently drops memberless group entities可能已有人在做 @Adelagric 于 33 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
PolicyEngine/policyengine-core#547 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 57/100
PolicyEngine/policyengine-core#614 ·
维护者通常 2 天内回复
-
A reform simulation's baseline reads the reform's default for people the situation gives no value可能已有人在做 @MaxGhenis 于 1 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
PolicyEngine/policyengine-core#612 ·
维护者通常 2 天内回复
查看 PolicyEngine/policyengine-core 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
tharje/spooler-v2#20 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
Bump version of azure-servicebus可能已有人在做 @joostlek 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
home-assistant/core#186275 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 72/100