Skip to content

perf(store): avoid O(N²) catalog flush and path scan in reindex_paths#14

Merged
harehare merged 2 commits into
mainfrom
perf/reindex-catalog-flush
Jul 15, 2026
Merged

perf(store): avoid O(N²) catalog flush and path scan in reindex_paths#14
harehare merged 2 commits into
mainfrom
perf/reindex-catalog-flush

Conversation

@harehare

Copy link
Copy Markdown
Owner

reindex_paths() did a linear scan over all documents to find each file's existing DocumentId, and flushed the full on-disk catalog after every single added/updated file — turning an N-document reindex into O(N²) work. Build a path->(id, position) map once up front, and defer the catalog flush to a single call after the batch completes.

Benchmarked on 3000 changed files: 5.6s -> 0.17s.

harehare added 2 commits July 15, 2026 23:46
reindex_paths() did a linear scan over all documents to find each
file's existing DocumentId, and flushed the full on-disk catalog after
every single added/updated file — turning an N-document reindex into
O(N²) work. Build a path->(id, position) map once up front, and defer
the catalog flush to a single call after the batch completes.

Benchmarked on 3000 changed files: 5.6s -> 0.17s.
The use_mimalloc feature added the dependency and Cargo feature flag
but never set #[global_allocator], so it had no effect on the binary.
@harehare
harehare merged commit 1c16769 into main Jul 15, 2026
6 checks passed
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