Repository navigation
perf(search-index): read source files concurrently and write the index compact - #1240
Merged
jeff-r2026 merged 2 commits intoOct 21, 2026
Merged
Conversation
The pretty-printed index is 15.4 MB at 5,000 learnings and 8.6 MB compact. Every reader parses it with JSON.parse, so the format does not matter to them, and a load reads and parses 24% faster. Refs Tencent#1239
A build read and parsed each file before it opened the next, so at 5,000 learnings the main thread waited on the disk for about 240 ms. The collectors now read through one helper that keeps 32 reads in flight. It returns the entries, and records the unreadable files, in listing order, because that order breaks score ties and names the files in the warning. The previous index is loaded once and shared, so concurrent reads put back the same entry objects. Refs Tencent#1239
|
No findings in the specified PR diff. The PR description documents sufficient testing: representative real-CLI Review was read-only; I did not run, build, or install anything from the PR. |
jeff-r2026
approved these changes
Oct 21, 2026
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
Step 1 of #1239. The full index rebuild that every
pullruns gets cheaper, with no cache, so it cannot serve a stale index. Reusing unchanged entries (step 2) is left out until this lands and #1233 is settled.indexInMemory collectLearningsEntries # roots in precedence order, as before collectFlatMdEntries / namespaces - for each file: await entryFromMdFile + entriesFromMdFiles # 32 reads in flight, each result kept in its listing slot collectListedMdEntries / collectRecursiveMdEntries / collectSkillDirEntries - for each file: await entryFromMdFile + entriesFromMdFiles buildIndex - writeJsonAtomic(index) # indented, 15.4 MB at 5,000 learnings + writeJsonAtomic(index, compact) # 8.6 MBEntries and the unreadable files named in the warning keep the order a sequential read gives, because that order breaks score ties. The previous index is loaded once and shared, because
reads.keptdedupes previous entries by object identity.Evidence
Real CLI, unchanged
pullon a synthetic team repo with 5,000 learnings, 6 runs per side, base and branch alternating:After: index build 902 ms [894-925], pull 1288 ms
The parsed index, without
builtAtandelapsedMs, hashes the same on both sides at 1,000 and 5,000 learnings. All 24 pulls exit 0 with no warnings. A CPU profile of the new build shows main-thread idle down from 243 ms to 23 ms. The build is now bound by tokenization on one core (57%). Reading and parsing the compact index takes 27 ms, against 35 ms for the indented one.New test
search-index-read-order.test.ts:It fails on the first version of this change, which recorded unreadable files as reads finished. It also fails on a mutation that pushes entries as reads finish. It passes on this branch.
tsc --noEmit, lint, and the full unit suite (11320 tests) pass.Merge Danger
Door: two-way
Reverting the two commits restores the sequential build. The next
pullrewrites the index, and every reader parses either format.Blast Radius: index-build
JSON.parse. A person or script that readssearch-index.jsonline by line sees one line now.skillsDirwalk, used only byviz, stays sequential.Refs #1239