gabriel / muse public
perf BREAKING task/perf-stat-cache-and-manifest-cache #1 / 1
gabriel · 166 days ago · Apr 14, 2026 · Diff

perf: stat cache for code add; manifest cache for log

- code_stage.py: replace hash_file() with StatCache.get_object_hash() so repeat 'muse code add' on unchanged files hits the inode+mtime+size cache instead of rehashing from disk. Cache saved atomically after each add run.

- log.py: introduce _ManifestCache (dict[commit_id, manifest]) shared across _commit_touches_path, _file_diff, and _commit_to_json within a single run. Previously pathspec filtering + JSON stat mode read the same snapshot 4× per commit (current+parent in each function); now each commit_id is fetched at most once.

Tests (TDD): - TestStatCacheIX (4 tests): structural check, cache-hit on unchanged file, cache file written, cache miss on modified file. - TestManifestCache (3 tests): structural check, each commit_id read ≤1×, pathspec filter correctness with cache active.

sha256:4f85f1ba8ffc81876a35569e4f63559e57fb7c0d3110d36af3752ebc3ed8ee2b sha
+12 ~5 −1 symbols
sha256:8e8011cba84ba66c1689fe579e83e664f294e9eb48e360931135674f0638295d snapshot
+12
symbols added
~5
symbols modified
−1
symbol removed
0
dead code introduced
Semantic Changes 18 symbols
~ muse/cli/commands/code_stage.py .py 1 symbol added, 1 symbol removed, 1 symbol modified
− hash_file import import hash_file L50–50
+ load_cache import import load_cache L50–50
~ muse/cli/commands/log.py .py 2 symbols added, 4 symbols modified
+ _ManifestCache variable variable _ManifestCache L109–109
+ _get_manifest function function _get_manifest L112–125
~ run
~ tests/test_cmd_code_add.py .py 5 symbols added
+ TestStatCacheIX class class TestStatCacheIX L897–971
+ test_IX1_stat_cache_used_structurally method method test_IX1_stat_cache_used_structurally L900–908
+ test_IX2_hash_file_not_called_on_unchanged_file method method test_IX2_hash_file_not_called_on_unchanged_file L910–935
+ test_IX3_stat_cache_file_written_after_add method method test_IX3_stat_cache_file_written_after_add L937–947
+ test_IX4_modified_file_is_rehashed method method test_IX4_modified_file_is_rehashed L949–971
~ tests/test_cmd_log.py .py 4 symbols added
+ TestManifestCache class class TestManifestCache L865–946
+ test_each_commit_id_read_at_most_once method method test_each_commit_id_read_at_most_once L887–927
+ test_manifest_cache_used_structurally method method test_manifest_cache_used_structurally L877–885
+ test_pathspec_filter_correct_with_cache method method test_pathspec_filter_correct_with_cache L929–946
← Older Oldest on task/perf-stat-cache-and-manifest-cache
All commits
Newer → Latest on task/perf-stat-cache-and-manifest-cache

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:4f85f1ba8ffc81876a35569e4f63559e57fb7c0d3110d36af3752ebc3ed8ee2b --body "your comment"