Repository navigation
perf(repo): walk only the --all delta after the HEAD pass - #75
Merged
Merged
Conversation
Follow-up on PR #74 (d181468e), from the maintainer's review note: getLoreIdIndex walked HEAD history twice. The HEAD pass seeds every reachable id, then the --all pass re-walked and re-parsed those same commits before first-wins deduplication discarded the duplicate work. On small repositories the cost is unmeasurable; on a 1.4M-commit corpus (issue #55) every index build pays the double walk. The index now resolves HEAD once, walks exactly that pinned commit, then runs git log --all --not <pin> for the delta. Resolving before walking is what makes the pin sound under concurrency: the first pass always walks exactly the commit the second pass excludes, so the exclusion boundary stays self-consistent under concurrent branch movement or landing commits - walked history is never dropped from the delta pass and new history is never hidden from it (which duplicate of a mid-build-landing shared Lore-id wins first-wins remains timing-dependent, as it was before). Plain --all remains the fallback whenever HEAD cannot be resolved (unborn HEAD on a fresh repository, a single --all walk) or the pinned walk fails (the exclusion is given up so --all covers HEAD). Semantics are unchanged: pinned-pass atoms are inserted first and the delta pass only fills missing ids, so a side branch can never shadow the current branch (issue #57), and newest-first first-wins within each pass keeps the same atom a grep-based findByLoreId returns. Coverage: unit tests pin the exact args of both passes in all three paths (pinned walk then delta; unresolved HEAD, single --all; walk failure then plain --all), and a real-git integration test asserts the index itself holds the side-branch-only id and lets the HEAD-reachable atom win the shared id, alongside the existing shadowing and unborn-HEAD integration tests. Lore-id: de1d01a2 Constraint: Resolve HEAD before walking and walk the pinned commit: the pin must always equal what the first pass walked, or the delta exclusion can misclassify history under concurrent branch movement. Constraint: Unresolved HEAD and failed pinned walk both keep the plain --all fallback, so the union of the passes never shrinks below git log --all. Constraint: Index semantics stay identical to PR #74: HEAD-reachable atoms win, delta pass fills only missing ids, first-wins within each pass. Tested: npm run typecheck: clean Tested: Full suite on Windows: 508 tests in 34 files, all passing Tested: Unit: pass-1 args are [pin], pass-2 args ['--all', '--not', pin] after a successful walk; unresolved HEAD runs a single ['--all'] walk; a failed pinned walk falls back to ['--all'] with head atoms retained Tested: Real-git integration: the index holds the side-branch-only id (cafe1234) and the HEAD-reachable atom wins the shared id (deadbeef); existing unborn-HEAD and shadowing integration tests pass Related: d181468e Confidence: high Scope-risk: narrow Reversibility: clean
This was referenced Nov 3, 2026
Collaborator
Author
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.
Follow-up to the review note on #74:
getLoreIdIndexwalked HEAD history twice. The HEAD pass seeds every reachable id, then the--allpass re-walked and re-parsed those same commits before first-wins deduplication discarded the duplicate work. Unmeasurable on small repos; on the 1.4M-commit corpus from #55 every index build pays the double walk.Design: resolve first, walk the pin.
getLoreIdIndexnow resolves HEAD once, walks exactly that pinned commit, then runsgit log --all --not <pin>for the delta. Resolving before walking is what makes the pin sound under concurrency: the first pass always walks exactly the commit the second pass excludes, so a landing commit or a concurrent branch switch can neither exclude walked history from the delta pass nor hide new history from it. Plain--allremains the fallback whenever HEAD cannot be resolved (unborn HEAD: a single--allwalk) or the pinned walk fails (the exclusion is given up so--allcovers HEAD) - the union of the passes never shrinks belowgit log --all.Semantics unchanged: pinned-pass atoms insert first, the delta pass fills only missing ids (a side branch can never shadow the current branch, #57), newest-first first-wins within each pass matches grep-based
findByLoreId.Tests: unit tests pin the exact args of both passes in all three paths (pinned walk then delta; unresolved HEAD, single
--all; failed walk, plain--all); a real-git integration test asserts the index holds the side-branch-only id and the HEAD-reachable atom wins the shared id. Typecheck clean, full suite 508/508 on Windows.Happy to benchmark against a large corpus (e.g. the blobless kernel clone from #55) if useful.