perf(server): cut idle CPU use and stop provider event leaks #8187
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 5 commits into
main fromrefs/pull/8187/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/project/RepositoryIdentityResolver.ts line 152Resolvedby t3dotgg(GitHub profile, opens in a new tab)@@ -139,3 +139,15 @@139139 options: RepositoryIdentityResolverOptions = {},140140 ) {141141 const processRunner = yield* ProcessRunner.ProcessRunner;142+ const cacheCapacity = options.cacheCapacity ?? DEFAULT_REPOSITORY_IDENTITY_CACHE_CAPACITY;143+144+ const repositoryRootCache = yield* Cache.makeWith<string, string>(145+ (cwd) =>146+ resolveRepositoryIdentityCacheKey(cwd).pipe(147+ Effect.provideService(ProcessRunner.ProcessRunner, processRunner),148+ ),149+ {150+ capacity: cacheCapacity,151+ timeToLive: () => options.positiveCacheTtl ?? DEFAULT_POSITIVE_CACHE_TTL,152+ },153+ );
- apps/server/src/provider/Layers/EventNdjsonLogger.ts lines 48 to 57Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -45,3 +45,11 @@4545 "tool.progress",4646 "turn.proposed.delta",4747 ]);48+const transientNativeMethods = new Set([49+ "item/agentMessage/delta",50+ "item/commandExecution/outputDelta",51+ "item/fileChange/outputDelta",52+ "item/plan/delta",53+ "item/reasoning/summaryTextDelta",54+ "item/reasoning/textDelta",55+]);packages/effect-codex-app-server/src/protocol.ts line 293OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -285,3 +289,5 @@285289 ),286290 onSuccess: (result) => respond(request.id, result),287291 }),292+ Effect.catch((error) => handleTermination(() => Effect.succeed(error))),293+ Effect.forkIn(protocolScope, { startImmediately: true }),native/resource-monitor/src/main.rs lines 467 to 467OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -455,4 +464,4 @@455464 .with_memory()456465 .with_cpu()457466 .with_disk_usage()458- .with_cmd(UpdateKind::Always)467+ .with_cmd(UpdateKind::OnlyIfNotSet)packages/effect-codex-app-server/src/protocol.ts line 293OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -285,3 +289,5 @@285289 ),286290 onSuccess: (result) => respond(request.id, result),287291 }),292+ Effect.catch((error) => handleTermination(() => Effect.succeed(error))),293+ Effect.forkIn(protocolScope, { startImmediately: true }),
- apps/server/src/provider/Layers/EventNdjsonLogger.ts line 219Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -186,0 +199,21 @@199+ }200+ if (stream !== "native") return true;201+202+ const nested = Reflect.get(event, "event");203+ const nativeEvent = typeof nested === "object" && nested !== null ? nested : event;204+ const method = Reflect.get(nativeEvent, "method");205+ if (206+ typeof method === "string" &&207+ (transientNativeMethods.has(method) ||208+ method.startsWith("claude/stream_event/content_block_delta/"))209+ ) {210+ return false;211+ }212+213+ const nativeType = Reflect.get(nativeEvent, "type");214+ if (nativeType === "message.part.delta") return false;215+216+ const payload = Reflect.get(nativeEvent, "payload");217+ if (typeof payload !== "object" || payload === null) return true;218+219+ if (method === "session/update") {packages/effect-codex-app-server/src/protocol.ts line 332Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -285,6 +308,7 @@285308 ),286309 onSuccess: (result) => respond(request.id, result),287310 }),288- )289- : Effect.void,290- ),311+ Effect.ensuring(312+ Ref.update(activeRequestHandlers, (count) => Math.max(0, count - 1)),313+ ),314+ Effect.catch((error) =>
- apps/server/src/provider/acp/AcpNativeLogging.ts line 88OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -66 +68,21 @@666869+function isTransientProtocolMessage(message: unknown): boolean {70+ if (typeof message !== "object" || message === null) return false;71+ const method = Reflect.get(message, "tag") ?? Reflect.get(message, "method");72+ if (method !== "session/update") return false;73+74+ const payload = Reflect.get(message, "payload") ?? Reflect.get(message, "params");75+ if (typeof payload !== "object" || payload === null) return false;76+ const update = Reflect.get(payload, "update");77+ if (typeof update !== "object" || update === null) return false;78+ const updateType = Reflect.get(update, "sessionUpdate");79+ return typeof updateType === "string" && transientProtocolUpdates.has(updateType);80+}81+82+function isTransientProtocolLog(event: EffectAcpProtocol.AcpProtocolLogEvent): boolean {83+ if (event.direction !== "incoming") return false;84+85+ const payload = event.payload;86+ if (event.stage === "raw" && typeof payload === "string") {87+ return (88+ payload.includes('"session/update"') &&apps/server/src/provider/acp/AcpNativeLogging.ts line 165Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -111,4 +143,4 @@111143 kind: "request",112144 payload: formatRequestLogPayload(event),113145 }),114- ...(input.nativeEventLogger146+ ...(input.nativeEventLogger && input.verboseProtocolLogging
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
3f8e2448-7614-4317-837b-9608c594ac05You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.