ref:main
perf: optimize merge_base with commit cache and 3-way tree merge with pointer walk and subtree fast paths #56
open
cole.christensen@gmail.com wants to merge
perf/merge-and-merge-base-optimizations
into main
No CI
Mergeable
Summary
Pure algorithmic performance optimizations for merge-base computation and three-way tree merging:
-
ExGitObjectstore.Walk.merge_base/4:- Single-read commit caching during priority walk: parsed commit structs and timestamps are cached in-memory so no commit object is decompressed more than once.
- Early termination: stops traversal as soon as common ancestor (
:both) is identified, avoiding deep traversal down shared root history.
-
ExGitObjectstore.Merge.merge_trees/5:- Subtree short-circuiting: if subtree SHAs match across
base == ours,base == theirs, orours == theirs, the untouched subtree is taken immediately without opening, reading, or descending into unmodified directories. - Three-way linear pointer merge: traverses
base_entries,ours_entries, andtheirs_entriessimultaneously comparing entry names without intermediate Map allocations, list flattening, deduplication, or re-sorting. - Speculative merge mode (
write: false): checks mergeability in memory without writing merged blobs or tree objects to disk storage.
- Subtree short-circuiting: if subtree SHAs match across
Created Sep 01, 2026 at 13:53 UTC