ref:main
perf: optimize diff and graph algorithms matching official git client #55
merged
cole.christensen@gmail.com wants to merge
perf/diff-and-graph-optimizations
into main
No CI
Summary
Optimizes tree diffing, Myers line diffing, and graph reachability queries based on the official Git C client architecture:
-
Myers Diff Line Interning & Single-Pass Hunk Builder (
ExGitObjectstore.Diff.Myers,ExGitObjectstore.Diff):- Interns unique line strings to small integer IDs (
0..N-1) during diffing so the Myers snake traversal executes single-cycle BEAM integer comparisons instead of comparing full binary terms. - Replaced multi-pass Erlang
:arraytree building with single-pass tuple indexing in hunk construction.
- Interns unique line strings to small integer IDs (
-
Single-Pass Decompression & Size Guard (
ExGitObjectstore.Diff.diff_blobs/4):- Added
:max_bytessize limit support todiff_blobs/4so oversized files are stubbed immediately during single read without redundant decompression.
- Added
-
Scheduler Parallelization (
ExGitObjectstore.Diff.diff_commits/4):- Diffing individual files within a commit diff is now parallelized across BEAM schedulers using
Task.async_stream/3.
- Diffing individual files within a commit diff is now parallelized across BEAM schedulers using
-
Two-Pointer Tree Merge Walk (
ExGitObjectstore.Diff.diff_trees/3):- Replaced
MapSet.union+Enum.sortwith a two-pointer linear merge walk over sorted tree entries matching Git’stree-walk.c:traverse_trees.
- Replaced
-
Early-Exit Graph Traversal (
ExGitObjectstore.Graph.Fallback):ancestor?/4now performs an early-exit BFS stopping immediately once the target commit is reached.ahead_behindandahead_behind_manystop following parent branches the moment they reach commits already known to belong to the base history.
Created Sep 01, 2026 at 03:55 UTC
| Merged Sep 01, 2026 at 04:33 UTC
by
cole.christensen@gmail.com