First file search in a project waits on a second walk of every folder to find symlinks: 551 ms of a 1.25 s first @-mention on Windows
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #39644 của @juliusmarminge — đã đóng, không merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- node.js, typescript
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Read apps/server/src/workspace/WorkspaceSearchIndex.ts, focusing on make, searchNames, and scanSymlinkEntries; the issue reports that symlink discovery rereads 4,703 indexed folders and blocks the first search. Start by tracing how fff builds its index and how symlink results are filtered after loadIgnoredPaths. Reproduce with the cold-search steps in the issue and compare the first-search trace; done means the search avoids or reduces the extra directory walk while still finding symlinks.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What is slow
The first file search in a project (the first @ mention in the composer, or the first file-picker query) waits until the server has built that project's search index. Most of that wait is spent finding symlinks. The server reads every folder the index already holds a second time, with one readdir per folder, and the search does not answer until that walk is done. The index is dropped after 15 minutes without a search (WORKSPACE_INDEX_IDLE_TTL), so a user pays this again whenever they come back to a project.
Measured
- Windows Server 2025, 4 vCPU, 16 GB, NTFS, Git for Windows, Node 26.13.1. Linux comparison: Linux VM, ext4.
- Commit
f2d4df0367. - Seed: a checkout of this repository itself, 32,715 tracked files in 4,702 folders, 17 tracked symlinks.
- Five runs per platform. Each run starts a fresh server on a fresh data dir (
T3CODE_DEV_SEED=0), then sends oneprojects.searchEntrieswith querymanager, limit 100. Times are server span durations fromserver.trace.ndjson.
| Windows median (range) | Linux median (range) | |
|---|---|---|
ws.rpc.projects.searchEntries (first search) |
1,253 ms (1,228-1,425) | 299 ms (244-431) |
WorkspaceSearchIndex.scanSymlinkEntries |
551 ms (502-623) | 207 ms (172-251) |
WorkspaceSearchIndex.loadIgnoredPaths (git ls-files --ignored) |
661 ms (630-761) | 59 ms (52-87) |
WorkspaceSearchIndex.scanDirectory spans in the first search |
4,703 | 4,703 |
Later searches in the same project take 18-32 ms on Windows. The symlink scan is the largest single part of the first search on Linux and about 44% of it on Windows.
How to measure it again
- Check out the commit, then run
vp i. - Start a server on a fresh data dir from
apps/server:T3CODE_DEV_SEED=0 node src/bin.ts serve --base-dir <fresh-dir> --port 39880 --host 127.0.0.1 - Save this as
apps/server/zz-search.tsand runnode zz-search.ts http://127.0.0.1:39880 <fresh-dir> <path-to-a-large-repo>:
import * as NodeServices from "@effect/platform-node/NodeServices";
import * as NodeWS from "@effect/platform-node/NodeWS";
import { ORCHESTRATION_PROTOCOL_VERSION, WsRpcGroup } from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import { RpcClient, RpcSerialization } from "effect/rpc";
import { Socket } from "effect/socket";
import { execFileSync } from "node:child_process";
const [origin, home, cwd] = process.argv.slice(2);
const token = execFileSync(process.execPath, ["src/bin.ts", "auth", "session", "issue", "--token-only", "--base-dir", home], { encoding: "utf8" }).trim();
const { ticket } = await (await fetch(`${origin}/api/auth/websocket-ticket`, { method: "POST", headers: { authorization: `Bearer ${token}` } })).json();
await Effect.runPromise(Effect.gen(function* () {
const protocol = yield* Layer.build(RpcClient.layerProtocolSocket().pipe(
Layer.provide(Socket.layerWebSocket(`${origin.replace(/^http/, "ws")}/ws?orchestrationProtocol=${ORCHESTRATION_PROTOCOL_VERSION}&wsTicket=${encodeURIComponent(ticket)}`)),
Layer.provide(RpcSerialization.layerJson), Layer.provide(NodeWS.layerWebSocketConstructor)));
const client = yield* RpcClient.make(WsRpcGroup).pipe(Effect.provideContext(protocol));
for (let i = 0; i < 3; i++) {
const t = Date.now();
yield* client["projects.searchEntries"]({ cwd, query: "manager", limit: 100 });
console.log(`search_ms=${Date.now() - t}`);
}
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)));
process.exit(0);
- Wait about 10 s so the trace flushes. Stop the server, then read the spans of the first search from
<fresh-dir>/userdata/logs/server.trace.ndjson:
import json, sys
sp = [json.loads(l) for l in open(sys.argv[1]) if l.strip()]
root = min((s for s in sp if s["name"] == "ws.rpc.projects.searchEntries"), key=lambda s: int(s["startTimeUnixNano"]))
t0, te = int(root["startTimeUnixNano"]), int(root["endTimeUnixNano"])
kids = [s for s in sp if s["traceId"] == root["traceId"] and t0 <= int(s["startTimeUnixNano"]) <= te]
for s in kids:
if s["name"] in ("ws.rpc.projects.searchEntries", "WorkspaceSearchIndex.loadIgnoredPaths", "WorkspaceSearchIndex.scanSymlinkEntries"):
print(f'{(int(s["startTimeUnixNano"]) - t0) / 1e6:8.1f} {s["durationMs"]:8.1f} {s["name"]}')
print("scanDirectory:", sum(s["name"] == "WorkspaceSearchIndex.scanDirectory" for s in kids))
Repeat steps 2-4 with a new data dir each time, so every run starts cold.
Where the time goes
The code is in apps/server/src/workspace/WorkspaceSearchIndex.ts.
makewaits forloadIgnoredPaths()andwaitForIndexReady.searchNamesthen callslistSymlinkEntries. On the first read this startsscanSymlinkEntriesand waits for it in full.scanSymlinkEntriesasks fff for every indexed folder (listIndexedDirectories). It then runsscanDirectoryon each one, which isNodeFSP.readdir(..., { withFileTypes: true }), 16 at a time. That is 4,703 folder reads to find 17 links.
Timeline of one cold Windows first search (ms from the request):
1.4 8.1 WorkspaceSearchIndex.createFinder
9.7 621.9 WorkspaceSearchIndex.loadIgnoredPaths (git ls-files --others --ignored)
631.7 1.1 WorkspaceSearchIndex.waitForIndexReady
635.8 540.0 WorkspaceSearchIndex.scanSymlinkEntries (4,703 scanDirectory spans)
1193.1 ws.rpc.projects.searchEntries ends
Why it is avoidable
The tree has just been walked by fff. The server then walks every folder again only to find the few symlinks fff skips, and the first search waits for that walk. The walk also starts only after the git ignored-paths listing, although it does not need that listing until it filters its result.
Found by the automated Windows performance sweep on f2d4df0367.
- Ngôn ngữ chính
- TypeScript
- Star
- 24.8k
- Fork
- 6.4k
- Merge trung bình
- 4 giờ 29 phút
- Pull request đã merge (30 ngày)
- 488
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pingdotgg/t3code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs more info
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pingdotgg/t3code#39400 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Wrapped PR titles lose bottom padding in the thread details panelCó thể đã có người làm @iamdatvt94 đã nhận 1 ngày trước. Đang mởbug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pingdotgg/t3code
Issue tương tự
-
area:plugins kind:bug priority:p2 ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Escaped `*` followed by `*` (`\**`) never matchesCó thể đã có người làm @bardrop đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
editorconfig/editorconfig-core-js#172 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vega/vega-webgpu#40 ·
-
Adjust break point sizingĐang mởtype: bug 🐛
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
puckeditor/puck#1929 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
compression() compresses every response at Brotli quality 11Có thể đã có người làm @staylor đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày