fix(server): first file search no longer waits on Git's ignored files to start the symlink scan #39644
main fromrefs/pull/39644/head·opened View on GitHubThe first @-mention or file-picker search in a project waited for the git ignored-files listing to finish before the server even started scanning folders for symlinks, and then for the whole scan. This also happened again after the index expired from 15 idle minutes. The scan now runs alongside the git listing, and its per-folder work is cheaper. On Windows the first search drops from about 1.7 s to about 1.0 s, with the same results.
WorkspaceSearchIndex.makestarts the symlink scan as soon as fff's index is ready, alongsideloadIgnoredPaths. The ignored paths are still applied when the scan result is read.scanDirectoryis no longer traced. It runs once per indexed folder, and a span on each call cost more than the folder read.
Fixes pingdotgg/t3code#39625
Reproduction on main#
Commit ed203c46cb (origin/main). Windows Server 2025 (leased pool machine, NTFS, Node 26.12.1): worktree at ed203c46cb, vp i, then per run a fresh data dir, T3CODE_DEV_SEED=0 node src/bin.ts serve --base-dir <fresh> --port 39880 --host 127.0.0.1 started via Win32_Process Create, then the issue's zz-search.ts driver (projects.searchEntries, query 'manager', limit 100, 3 times) against a checkout of this repo (17 tracked symlinks, 4,671 indexed folders), wait 12 s, server stopped by its captured PID, and spans read from userdata/logs/server.trace.ndjson with the issue's analysis script. Run 1 (cold disk cache: first search 4,898 ms, git ignored-files listing 3,655 ms, symlink scan 901 ms) was discarded. Runs 2-6: first search 2,021 / 1,709 / 1,694 / 1,666 / 1,578 ms, median 1,694 (range 1,578-2,021). WorkspaceSearchIndex.scanSymlinkEntries 686 / 1,038 / 963 / 992 / 890 ms, median 962 (686-1,038). loadIgnoredPaths 1,018 / 615 / 689 / 635 / 630 ms, median 635 (615-1,018). listIndexedDirectories 86-140 ms. 4,671 scanDirectory spans in every first search. Later searches 22-41 ms. The symlink scan always starts only after loadIgnoredPaths and waitForIndexReady finish. Linux baseline (this VM, same driver and steps, target a worktree checkout of the repo, 4,703 folders): runs 2-6 first search 285 / 274 / 446 / 249 / 980 ms, median 285 (249-980; run 6 looks like VM noise). scanSymlinkEntries median 198 (164-797). loadIgnoredPaths median 82 (52-132). Later searches 7-27 ms.
Evidence#
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests#
vp test run src/workspace/WorkspaceSearchIndex.test.ts src/workspace/WorkspaceEntries.test.ts(apps/server): 2 files, 51 tests passedvp run typecheck(apps/server): no errors (only existing schemaClassMissingBrand suggestions)- pre-commit
vp fmt,vp lint,vp run knip:check: passed vp run check:changed: exit 0 (2 test files, 19 tests passed)- Issue's zz-search.ts driver plus span analysis, 6 fresh-server runs before and after, on Windows Server 2025 and on Linux: numbers in summary
Not in this change#
- The first search on Windows is now bounded by
loadIgnoredPaths(git ls-files --others --ignored, about 800 ms there), which this change does not touch. - The symlink scan still reads every indexed folder, because fff 0.11 cannot report the symlinks it skips. Avoiding the walk would mean another source for links, such as git's index plus untracked files, which is a redesign.
- libuv's default threadpool of 4 caps how many folder reads run at once, whatever SYMLINK_SCAN_CONCURRENCY is set to.
Who did the work#
- Written by Claude Opus 5.5, in Claude Code
- Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
- Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
Run by the t3code factory in T3 Code.
- 1
- 2
Pushed878b742
juliusmarminge closed this
Sign in to join this conversation.
Three rounds of review did not settle this fix, so it is closed and written again from main. The new pull request will link here.