Commit 41fe555
committed
commit-reach: add general graph traversal find_reachable()
Add find_reachable(), a generalization of the memoized DFS in
can_all_from_reach_with_flag().
The benefits are two-fold:
1. make the code more uniform - fewer core graph traversals
to maintain and reason about.
2. optimization for ref-filter --contains
Most converted callers get equal or slightly better performance,
since this standardizes on the generally "best" implementation.
The big win is ref-filter --contains/--no-contains.
Instead of calling commit_contains() for each ref, we batch it
into batched calls to find_reachable(), changing the time complexity
from O(N * D) to O(D + N) where D is the reachable graph depth and
N is the number of refs.
The removed contains_tag_algo used the same memoized DFS approach
with a commit slab instead of flag bits; the batched
find_reachable_list produces identical results, as confirmed by
the existing test suites (t7004-tag, t3201-branch-contains,
t6302-for-each-ref-filter, t6600-test-reach: 370 tests total).
Signed-off-by: Kristofer Karlsson <krka@spotify.com>1 parent 9ac3f19 commit 41fe555
6 files changed
Lines changed: 240 additions & 288 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
| |||
0 commit comments