fangorn/ex_git_objectstore
public
ref:1f149a1f725cda30241b369a6a5bb3f38001552d
perf: graph cache mtime freshness + walk-base-once in fallback (#26)
Two related fixes from investigating fangorn/anvil's 2.6 s PR-list mount.
Adds Storage.blob_fingerprint optional callback (Filesystem returns mtime+size, others :unsupported) so Graph.Cache.fetch/2 can return :stale when the on-disk graph has been rewritten by a separate VM. Without this, 'mix anvil.graphs.rebuild' from a separate shell never reaches the running app's persistent_term cache — that's why the rebuild was 'briefly effective then gone'.
Adds Graph.Fallback.ahead_behind_many/4 (walks ancestors(base) once and reuses it across heads). The old fill_per_head/4 was O(N · |ancestors(base)|) which on fangorn/anvil with ~50 PRs against a few-hundred-commit base was the actual reason the slow path was multi-second, not just slow.
API change: Graph.Cache.fetch/1 -> fetch/2 and put/2 -> put/3 (added fingerprint arg; pass Cache.no_fingerprint() for old behaviour).
## Test plan
- [x] 924 tests / 0 failures
- [x] New tests cover walk-once correctness (vs per-call), cache freshness transitions, and an end-to-end "separate-process rewrite triggers reload" integration test.
- [x] mix format --check-formatted clean.
- [x] No new credo issues in changed files.
SHA:
1f149a1f725cda30241b369a6a5bb3f38001552d
Author:
Anvil <noreply@anvil.fangorn.io>
Date:
2026-05-06 01:54
Parents:
c38581b
9 files changed
+451
-57
| Type | ||
|---|---|---|
|
|
lib/ex_git_objectstore.ex | +38 −10 |
|
||