Skip to content

perf(sync): index notes by gitPath in pull classifier#194

Open
rotecodefraktion wants to merge 1 commit into
ipapakonstantinou:devfrom
rotecodefraktion:perf/sync-index-notes-by-gitpath
Open

perf(sync): index notes by gitPath in pull classifier#194
rotecodefraktion wants to merge 1 commit into
ipapakonstantinou:devfrom
rotecodefraktion:perf/sync-index-notes-by-gitpath

Conversation

@rotecodefraktion

Copy link
Copy Markdown

What changed

The pull classifier ran notes.find(n => n.gitPath === path) in three
separate loops — O(remoteFiles x notes) per pass. Now a single
Map<gitPath, Note> is built once (first-wins, preserving find's
first-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 lint
  • npm run typecheck (clean)
  • npm testgithubSyncClassify, githubSyncRoundtrip, githubSyncGaps, syncPullWritesSnapshot, githubSyncSafetyNet: 104 pass
  • npm run build
  • Ran npm run e2e:sync? No — pure refactor of in-memory classification, no API/round-trip behavior change; covered by the classify/roundtrip unit suites above.
  • UI change? n/a

Notes

Single-file change (src/utils/githubSync/syncPull.ts).

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant