perf(sync): index notes by gitPath in pull classifier#194
Open
rotecodefraktion wants to merge 1 commit into
Open
perf(sync): index notes by gitPath in pull classifier#194rotecodefraktion wants to merge 1 commit into
rotecodefraktion wants to merge 1 commit into
Conversation
Three loops each ran notes.find(n => n.gitPath === path) per remote file — O(remote x notes) per pass. Build a Map<gitPath, Note> once (first-wins, preserving find's first-match semantics) and use O(1) lookups instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What changed
The pull classifier ran
notes.find(n => n.gitPath === path)in threeseparate loops —
O(remoteFiles x notes)per pass. Now a singleMap<gitPath, Note>is built once (first-wins, preservingfind'sfirst-match semantics) and used for
O(1)lookups.Why
On large vaults the per-file linear scans dominated pull-classification
time. Indexing once removes the quadratic factor with identical results.
How it was tested
npm run lintnpm run typecheck(clean)npm test—githubSyncClassify,githubSyncRoundtrip,githubSyncGaps,syncPullWritesSnapshot,githubSyncSafetyNet: 104 passnpm run buildnpm run e2e:sync? No — pure refactor of in-memory classification, no API/round-trip behavior change; covered by the classify/roundtrip unit suites above.Notes
Single-file change (
src/utils/githubSync/syncPull.ts).