Copy the full-data packet once per report, not once per domain (issue #122, BUG-1471)
Independent Staging Quality Gate / validate (push) Successful in 15m27s
Independent Staging Quality Gate / publish (push) Successful in 3m43s

read_full_data_domain deep-copied the shared worksheets on every call; a long
report reads five domains twice, so ten copies for read-only use. The shared
part is now copied once (full_data_domain_base) and reused for every domain's
facts and their leaf check; each domain's facts are still copied out so domains
share no objects. Long reports byte-identical on four fictional charts; with
#121, -24–29% end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoz1Qk3y9buDv1mkmTu
This commit is contained in:
Jesse_Chen
2026-10-28 07:06:32 +08:00
co-authored by Claude Opus 5.5
parent f8fa4d66ef
commit 3eeb898071
6 changed files with 99 additions and 17 deletions
+15
View File
@@ -20065,3 +20065,18 @@
- 复发自:BUG-1466(深色变体未覆盖)
- 修复版本:分支 `codex/ui-polish-140-20261028`。
## BUG-1471 | 长报告与咨询数据卡每个领域都把整份数据包深拷贝一遍
- 状态:resolved(代码 + 回归测试;待部署)
- 首次发现 / 最近更新:2026-10-28 / 2026-10-28(issue #118 代码体检 → #122)
- 影响面:个人长报告(模型写的「读盘」前置事实)、咨询数据卡;`scripts/pl9_full_data_export.py` `read_full_data_domain`、`scripts/consult_card_domain_facts.py`、`scripts/report_render/reading_facts.py`。
- 现象:长报告冷生成慢;profile 口径下整包 deepcopy 合计约 9 s,其中 `read_full_data_domain` 约 5 s。
- 触发条件:任何长报告生成、任何带数据卡的咨询轮。
- 根因:`read_full_data_domain` 每调一次就把 `worksheets` 等共享部分整份深拷贝。长报告读 5 个领域,生成事实一遍、逐条核对又一遍,共 10 份;读的人全是只读。
- 修复:新增 `full_data_domain_base`,同一个数据包只深拷一次;`read_full_data_domain(..., base=)` 复用它。`build_consult_card_facts` 每次调用只建一次,长报告的事实与核对共用同一份。各领域产出的事实再各自深拷贝(体量小),保持「不同领域的结果互不共享对象」与改前一致。
- 验证:`scripts/research/report_reference_perf_ab.py --mask-pyjhora`(四张虚构盘各三次)改前 / 改后、开关开 / 关全部组合下完整报告逐字节相同;与改前相比,叠加 #121 后端到端快 24%~29%(中位约 26%),单论本单在开关打开时再快 1%~7%。JSON 与参考版两项附加检查在改前代码上连跑两次即不同(输出自身跨进程不确定),无法用跨代码 sha 比对,已注明。新测试 `tests/test_consult_card_full_source.py::test_all_domains_share_one_packet_copy_and_still_match_the_per_domain_path`:只建一次共享拷贝、结果与逐领域路径一致、领域间不共享对象。Python 快速门全部 Python 步骤通过(前端 npm 步因本工作树无依赖未跑,本单无前端改动)。
- 防复发:上面的测试;只读用途的「视图」不要每次整份深拷贝,多处读同一包时共享一份。
- 关联:BUG-1335(同一份报告的出稿与哈希重复劳动,#121 已开快路径)。溯源哈希仍在出稿后由质量门重算一次以核对,这是有意的完整性检查,未合并。
- 复发自:无
- 修复版本:分支 `codex/report-fast-default-20261028`。