Skip to content

Commit f2dcc48

Browse files
perf(server): stop tracing project enrichment cache reads
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 065a433 commit f2dcc48

1 file changed

Lines changed: 52 additions & 48 deletions

File tree

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

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

213-
const requestLane = Effect.fn("ProjectEnrichmentService.requestLane")(function* (
213+
// Every project read lands here; only an actual enqueue gets a span, the resolve workers trace the work.
214+
const requestLane = Effect.fnUntraced(function* (
214215
lane: EnrichmentWorkLane,
215216
workspaceRoot: string,
216217
field: "repositoryIdentity" | "faviconPath",
217218
) {
218219
if (!(yield* reservePending(lane, workspaceRoot))) return;
219-
if (!(yield* Queue.offer(lane.queue, workspaceRoot))) {
220-
yield* removePending(lane, workspaceRoot);
221-
yield* Effect.logWarning("Project metadata enrichment queue is full", {
222-
workspaceRoot,
223-
field,
224-
});
225-
}
220+
yield* Effect.gen(function* () {
221+
if (!(yield* Queue.offer(lane.queue, workspaceRoot))) {
222+
yield* removePending(lane, workspaceRoot);
223+
yield* Effect.logWarning("Project metadata enrichment queue is full", {
224+
workspaceRoot,
225+
field,
226+
});
227+
}
228+
}).pipe(Effect.withSpan("ProjectEnrichmentService.requestLane"));
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+
// peek/request/getAvailable run per project on every shell read, inside the caller's span; own spans were ~0ms noise.
232+
const peek: ProjectEnrichmentService["Service"]["peek"] = Effect.fnUntraced(
233+
function* (workspaceRoot) {
234+
const [repositoryIdentity, faviconPath] = yield* Effect.all(
235+
[
236+
Cache.getSuccess(repositoryIdentityCache, workspaceRoot),
237+
Cache.getSuccess(faviconCache, workspaceRoot),
238+
] as const,
239+
{ concurrency: "unbounded" },
240+
);
241+
return {
242+
repositoryIdentity: availableValue(repositoryIdentity),
243+
faviconPath: availableValue(faviconPath),
244+
repositoryIdentityResolved: isSuccessfullyResolved(repositoryIdentity),
245+
};
246+
},
247+
);
244248

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-
});
249+
const request: ProjectEnrichmentService["Service"]["request"] = Effect.fnUntraced(
250+
function* (workspaceRoot) {
251+
const [hasRepositoryIdentity, hasFaviconPath] = yield* Effect.all(
252+
[Cache.has(repositoryIdentityCache, workspaceRoot), Cache.has(faviconCache, workspaceRoot)],
253+
{ concurrency: "unbounded" },
254+
);
255+
yield* Effect.all(
256+
[
257+
hasRepositoryIdentity
258+
? Effect.void
259+
: requestLane(repositoryIdentityLane, workspaceRoot, "repositoryIdentity"),
260+
hasFaviconPath ? Effect.void : requestLane(faviconLane, workspaceRoot, "faviconPath"),
261+
],
262+
{ concurrency: "unbounded", discard: true },
263+
);
264+
},
265+
);
262266

263-
const getAvailable: ProjectEnrichmentService["Service"]["getAvailable"] = Effect.fn(
264-
"ProjectEnrichmentService.getAvailable",
265-
)(function* (workspaceRoot) {
266-
const available = yield* peek(workspaceRoot);
267-
yield* request(workspaceRoot);
268-
return available;
269-
});
267+
const getAvailable: ProjectEnrichmentService["Service"]["getAvailable"] = Effect.fnUntraced(
268+
function* (workspaceRoot) {
269+
const available = yield* peek(workspaceRoot);
270+
yield* request(workspaceRoot);
271+
return available;
272+
},
273+
);
270274

271275
const readRepositoryIdentity: ProjectEnrichmentService["Service"]["readRepositoryIdentity"] =
272276
Effect.fn("ProjectEnrichmentService.readRepositoryIdentity")(function* (workspaceRoot) {

0 commit comments

Comments
 (0)