fix: stop find_nearest_bookmarked_ancestors re-walking merge ancestors combinatorially (RIG-3585) - #5
Draft
rigel-mintaka wants to merge 1 commit into
Draft
rigel-mintaka wants to merge 1 commit into
rigel-mintaka wants to merge 1 commit into
Conversation
…s combinatorially (RIG-3585) `find_nearest_bookmarked_ancestors` recursed with no visited set, re-expanding a shared ancestor once per path that reaches it — one `jj log` subprocess per visit. On a history with merge commits outside `trunk()` this is exponential in the number of merges: a 12-rung merge ladder spawns 8194 `jj` invocations and a real 136-commit / 26-merge repo did not terminate in 200s. Thread a `visited` set (keyed on commit id) through the recursion so each commit is expanded at most once. The set of boundary ancestors is unchanged — a boundary found on the first visit already bubbles to the root and the caller deduplicates via `BTreeSet` — so the walk becomes linear with identical output. A test-only `jj` subprocess counter on `Jujutsu` backs a regression test asserting the invocation count stays linear over a 12-rung merge ladder (8194 without the fix, well under 200 with it). Spec-impact: none. Refs RIG-3585 Co-authored-by: Matt Wilkinson <matt@rigel.build>
rigel-mintaka
force-pushed
the
upstream-vcs/rig-3585-rewalk-dedup
branch
from
September 11, 2026 23:24
c9286a7 to
090ae9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_nearest_bookmarked_ancestorsrecursed with no visited set, re-expanding a shared ancestor once per path that reaches it — onejj logsubprocess per visit. On a history with merge commits outsidetrunk()this is exponential in the number of merges: a 12-rung merge ladder spawns 8194jjinvocations and a real 136-commit / 26-merge repo did not terminate in 200s.Thread a
visitedset (keyed on commit id) through the recursion so each commit is expanded at most once. The set of boundary ancestors is unchanged — a boundary found on the first visit already bubbles to the root and the caller deduplicates viaBTreeSet— so the walk becomes linear with identical output. A test-onlyjjsubprocess counter onJujutsubacks a regression test asserting the invocation count stays linear over a 12-rung merge ladder (8194 without the fix, well under 200 with it).Spec-impact: none. Refs RIG-3585
Co-authored-by: Matt Wilkinson matt@rigel.build