Repository navigation
[perf] storage: cache a long project's whole commit history - #42
Merged
Merged
Conversation
## summary - Every project read validates the full commit chain, and each record holds a full project snapshot. The record cache kept at most 128 records or 8 MiB, so a longer history was reparsed from disk on every read. A 317-commit project (55 MB of records) took 3-13 s per snapshot on network storage. - Those reads held the catalog lock for as long, so session heartbeats and job checkpoints timed out: edit sessions expired and running generations were interrupted at submit, poll, download or save. - The cache now holds up to 4096 records or 512 MiB. The same project reads in about 0.05 s. Changed, replaced or missing records are still detected by their file signature before a cached record is reused. ## validation - `.venv/bin/python -m pytest tests -q`: 614 passed. The new `test_long_history_is_validated_from_disk_only_once` fails without this change. - `npm test`: 423 passed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
问题与改动
每次读取工程都要校验完整的提交链,而每条提交记录都存着一份完整的工程快照。原来的记录缓存最多只保留 128 条或 8 MiB,历史一长就装不下,每次读取都得从磁盘重新解析全部记录。
实际影响(本机,工程目录位于网络存储):一个有 317 条提交、记录共 55 MB 的工程,每次读取快照需要 3–13 秒。读取期间一直持有目录锁,导致:
改动:缓存上限提高到 4096 条或 512 MiB,写成具名常量并注明原因。复用缓存前仍按文件签名检查记录是否被修改、替换或删除,这条原有约束不变。
Test Plan
.venv/bin/python -m pytest tests -qnpm test.venv/bin/python scripts/generate_contracts.py --checkTest Result
test_long_history_is_validated_from_disk_only_once构造 200 条提交的工程,要求第二次读取时不再解析任何提交文件;该测试在修改前失败、修改后通过。未覆盖:
🤖 Generated with Claude Code