Skip to content

Commit bc2302e

Browse files
t3dotggclaude
andcommitted
fix(server): project lookups stop flooding the server trace
PR sync reads each linked project about once a minute, and each read wrote spans for cache peeks and for every favicon candidate path. These five microsecond helpers were 40% of all server spans, so the 10 trace files rotated every 5 to 15 minutes and kept about 2 hours of history. They are now untraced; their parent spans (getAvailable, ProjectService.hydrate, resolvePathUncached) still record the call and its timing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 21eb9a4 commit bc2302e

3 files changed

Lines changed: 42 additions & 36 deletions

File tree

‎apps/server/src/project/ProjectEnrichmentService.ts‎

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ export const make = Effect.fn("ProjectEnrichmentService.make")(function* (
210210
{ concurrency: "unbounded", discard: true },
211211
);
212212

213-
const requestLane = Effect.fn("ProjectEnrichmentService.requestLane")(function* (
213+
// requestLane, peek and request are cache reads that run on every project
214+
// shell read, so they stay untraced; getAvailable and ProjectService record
215+
// the call.
216+
const requestLane = Effect.fnUntraced(function* (
214217
lane: EnrichmentWorkLane,
215218
workspaceRoot: string,
216219
field: "repositoryIdentity" | "faviconPath",
@@ -225,40 +228,40 @@ export const make = Effect.fn("ProjectEnrichmentService.make")(function* (
225228
}
226229
});
227230

228-
const peek: ProjectEnrichmentService["Service"]["peek"] = Effect.fn(
229-
"ProjectEnrichmentService.peek",
230-
)(function* (workspaceRoot) {
231-
const [repositoryIdentity, faviconPath] = yield* Effect.all(
232-
[
233-
Cache.getSuccess(repositoryIdentityCache, workspaceRoot),
234-
Cache.getSuccess(faviconCache, workspaceRoot),
235-
] as const,
236-
{ concurrency: "unbounded" },
237-
);
238-
return {
239-
repositoryIdentity: availableValue(repositoryIdentity),
240-
faviconPath: availableValue(faviconPath),
241-
repositoryIdentityResolved: isSuccessfullyResolved(repositoryIdentity),
242-
};
243-
});
231+
const peek: ProjectEnrichmentService["Service"]["peek"] = Effect.fnUntraced(
232+
function* (workspaceRoot) {
233+
const [repositoryIdentity, faviconPath] = yield* Effect.all(
234+
[
235+
Cache.getSuccess(repositoryIdentityCache, workspaceRoot),
236+
Cache.getSuccess(faviconCache, workspaceRoot),
237+
] as const,
238+
{ concurrency: "unbounded" },
239+
);
240+
return {
241+
repositoryIdentity: availableValue(repositoryIdentity),
242+
faviconPath: availableValue(faviconPath),
243+
repositoryIdentityResolved: isSuccessfullyResolved(repositoryIdentity),
244+
};
245+
},
246+
);
244247

245-
const request: ProjectEnrichmentService["Service"]["request"] = Effect.fn(
246-
"ProjectEnrichmentService.request",
247-
)(function* (workspaceRoot) {
248-
const [hasRepositoryIdentity, hasFaviconPath] = yield* Effect.all(
249-
[Cache.has(repositoryIdentityCache, workspaceRoot), Cache.has(faviconCache, workspaceRoot)],
250-
{ concurrency: "unbounded" },
251-
);
252-
yield* Effect.all(
253-
[
254-
hasRepositoryIdentity
255-
? Effect.void
256-
: requestLane(repositoryIdentityLane, workspaceRoot, "repositoryIdentity"),
257-
hasFaviconPath ? Effect.void : requestLane(faviconLane, workspaceRoot, "faviconPath"),
258-
],
259-
{ concurrency: "unbounded", discard: true },
260-
);
261-
});
248+
const request: ProjectEnrichmentService["Service"]["request"] = Effect.fnUntraced(
249+
function* (workspaceRoot) {
250+
const [hasRepositoryIdentity, hasFaviconPath] = yield* Effect.all(
251+
[Cache.has(repositoryIdentityCache, workspaceRoot), Cache.has(faviconCache, workspaceRoot)],
252+
{ concurrency: "unbounded" },
253+
);
254+
yield* Effect.all(
255+
[
256+
hasRepositoryIdentity
257+
? Effect.void
258+
: requestLane(repositoryIdentityLane, workspaceRoot, "repositoryIdentity"),
259+
hasFaviconPath ? Effect.void : requestLane(faviconLane, workspaceRoot, "faviconPath"),
260+
],
261+
{ concurrency: "unbounded", discard: true },
262+
);
263+
},
264+
);
262265

263266
const getAvailable: ProjectEnrichmentService["Service"]["getAvailable"] = Effect.fn(
264267
"ProjectEnrichmentService.getAvailable",

‎apps/server/src/project/ProjectFaviconResolver.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ export const make = Effect.gen(function* () {
161161
return [path.join("public", clean), clean];
162162
};
163163

164-
const findExistingFile = Effect.fn("ProjectFaviconResolver.findExistingFile")(function* (
164+
// Untraced: one resolution checks about 20 candidates, and resolvePathUncached
165+
// already records the whole scan.
166+
const findExistingFile = Effect.fnUntraced(function* (
165167
projectCwd: string,
166168
relativeCandidates: ReadonlyArray<string>,
167169
candidateScope: "workspace" | "filesystem",

‎apps/server/src/workspace/WorkspacePaths.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ export const make = Effect.gen(function* () {
190190
return normalizedWorkspaceRoot;
191191
});
192192

193+
// Untraced: pure path math that favicon scans call for every candidate file.
193194
const resolveRelativePathWithinRoot: WorkspacePaths["Service"]["resolveRelativePathWithinRoot"] =
194-
Effect.fn("WorkspacePaths.resolveRelativePathWithinRoot")(function* (input) {
195+
Effect.fnUntraced(function* (input) {
195196
const normalizedInputPath = input.relativePath.trim();
196197
if (path.isAbsolute(normalizedInputPath)) {
197198
return yield* new WorkspacePathOutsideRootError({

0 commit comments

Comments
 (0)