gabriel / muse public
perf BREAKING dev
AI Agent gabriel · 161 days ago · Apr 19, 2026 · Diff

perf: wire StatCache into symbols_for_snapshot for 42× warm speedup

On a warm stat + symbol cache, symbols_for_snapshot(workdir=root) now skips read_bytes() entirely for every unchanged file. The SHA-256 cache key is derived from (ino, mtime, size) via StatCache.get_cached() — zero file reads on a warm stat-cache hit. Bytes are deferred to a _disk_for_miss variable and only loaded when the SymbolCache misses.

Benchmark (muse repo, 786 Python files): Cold: 292 ms → Warm: 6.9 ms (42× speedup)

TDD: 9 tests in tests/test_query_stat_cache.py — all green.

sha256:531ae4d1ecc4b1c92adcffb8980214c0e59f0be3110cba10a57292a3692710e2 sha
+29 ~1 symbols
sha256:7075201d7aa307d0f4a21cd0a2eaf47d445cfb0491463d4648299aaeaaded7f4 snapshot
+29
symbols added
~1
symbol modified
0
dead code introduced
Semantic Changes 30 symbols
~ tests/test_query_stat_cache.py .py 28 symbols added
+ TestAcceptsStatCache class class TestAcceptsStatCache L80–98
+ test_accepts_stat_cache_instance method method test_accepts_stat_cache_instance L86–90
+ test_accepts_stat_cache_none method method test_accepts_stat_cache_none L81–84
+ test_result_unchanged_with_or_without_stat_cache method method test_result_unchanged_with_or_without_stat_cache L92–98
+ TestStatCacheHitSkipsRead class class TestStatCacheHitSkipsRead L106–173
+ test_stat_cache_hit_symbol_cache_miss_reads_once method method test_stat_cache_hit_symbol_cache_miss_reads_once L143–173
+ test_warm_stat_and_symbol_cache_skips_read_bytes method method test_warm_stat_and_symbol_cache_skips_read_bytes L107–141
+ TestStatCacheIgnoredWithoutWorkdir class class TestStatCacheIgnoredWithoutWorkdir L210–219
+ test_no_read_bytes_called_for_committed_blobs method method test_no_read_bytes_called_for_committed_blobs L211–219
+ TestStatCacheInvalidation class class TestStatCacheInvalidation L227–249
+ test_edited_file_triggers_reread method method test_edited_file_triggers_reread L228–249
+ TestStatCachePopulated class class TestStatCachePopulated L181–202
+ test_stat_cache_file_created_on_disk method method test_stat_cache_file_created_on_disk L197–202
+ test_stat_cache_has_entry_after_workdir_call method method test_stat_cache_has_entry_after_workdir_call L182–195
+ _PY_SRC variable variable _PY_SRC L48–54
+ _PY_SRC_V2 variable variable _PY_SRC_V2 L56–62
+ _make_repo function function _make_repo L65–72
+ MagicMock import import MagicMock L32–32
+ StatCache import import StatCache L38–38
+ SymbolCache import import SymbolCache L39–39
+ annotations import import annotations L28–28
+ blob_id import import blob_id L36–36
+ hashlib import import hashlib L30–30
+ patch import import patch L32–32
+ pathlib import import pathlib L31–31
+ pytest import import pytest L34–34
+ symbols_for_snapshot import import symbols_for_snapshot L40–40
+ write_object import import write_object L37–37
~ muse/plugins/code/_query.py .py 1 symbol added, 1 symbol modified
+ StatCache import import StatCache L23–23
← Older Oldest on dev
All commits
Newer → Latest on dev

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:531ae4d1ecc4b1c92adcffb8980214c0e59f0be3110cba10a57292a3692710e2 --body "your comment"