perf: optimize merge_base with commit cache and 3-way tree merge with pointer walk and subtree fast paths #56

open colechristensen cole.christensen@gmail.com wants to merge perf/merge-and-merge-base-optimizations into main

Summary

Pure algorithmic performance optimizations for merge-base computation and three-way tree merging:

  1. 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.
  2. ExGitObjectstore.Merge.merge_trees/5:

    • Subtree short-circuiting: if subtree SHAs match across base == ours, base == theirs, or ours == 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, and theirs_entries simultaneously 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.
Created Sep 01, 2026 at 13:53 UTC