Cap BFS visits in compute_hidden_forks to prevent hangs#29
Open
eljaska wants to merge 2 commits into
Open
Conversation
c6a71ac to
77c4e3c
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.
Summary
query_bench) that measuresevaluate_revset_str,compute_hidden_forks, andget_pageacross four revset types on any jj repo. The test is#[ignore]and run manually viaBENCH_REPO=/path/to/repo cargo test query_bench -- --ignored --nocapture.compute_hidden_forksat 100,000 to prevent unbounded ancestor traversal when most bookmarks are outside the log revset.Context
PR #22 replaced the O(B × n) per-bookmark
evaluate_revset_exprcall with a BFS walk per out-of-log bookmark. The PR assumed "cost is O(depth_to_log) per bookmark, which is tiny in practice since bookmarks are usually a few commits off the log boundary." This holds when the log revset is large (e.g.all()or::@), since most bookmarks are already in-log or close to it. But with small log revsets likedefaultormine, nearly all ~4,000 bookmarks of stargate are out-of-log, and each BFS walks thousands of commits before finding a log ancestor — or never finds one. With no bound on total work, this causes an indefinite hang on startup for any repo with many bookmarks and a small default revset.Before (on master)
After (with BFS cap at 100k visits)
Test plan
BENCH_REPO=/path/to/repo cargo test query_bench -- --ignored --nocapturecompletes for all four revsetscargo test(non-ignored tests) still passes🤖 Generated with Claude Code