Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Every new system compiles its variable files again, which sys.monitoring coverage retains

未关闭
#607 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@MaxGhenis 已经在做这个了。

开始于 2026年10月11日。

  • #608 来自 @MaxGhenis —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PolicyEngine/policyengine-core 的其他 Issue

查看 PolicyEngine/policyengine-core 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。