Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): cut idle CPU use and stop provider event leaks #8187

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/8187/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

The server keeps scanning processes while idle and retains provider events after they have already been handled. High-volume logs, repeated Git discovery, and blocked Codex approvals add more work during active sessions.

This change bounds provider event buffers, keeps approvals off the protocol reader, cuts idle monitor scans by 80%, filters transient provider logs, skips unused provider output, and caches Git repository roots. Live diagnostics still refresh once per second.

Focused server and provider tests, the Codex and Claude transfer budget, package type checks, lint, and native resource monitor tests all pass.

Made with GPT-5.6 Sol in the Codex harness.


Note

Medium Risk Changes alter provider event handling, Codex request concurrency/shutdown semantics, and telemetry sampling cadence; mis-bounded buffers or filtered deltas could drop diagnostics or delay thread updates under extreme load.

Overview This PR reduces idle and hot-path work across provider ingestion, logging, Git identity resolution, native telemetry, and Codex/ACP wire protocols.

Provider runtime and logs: processRuntimeEvent now ignores non-assistant_text content.delta events and only loads pending turn-start state for session/turn lifecycle events. NDJSON persistence drops a broader set of transient canonical and native deltas (including ACP chunk updates), and verbose ACP protocol logging is opt-in via verboseProtocolLogging with chunk filtering before write.

Protocols: Codex and ACP transports use sliding queues (32) for buffered notifications/requests, Codex runs incoming request handlers on a forked scope with a 32 concurrent handler cap, and termination fails pending work and stops the stdin reader without blocking on handler cleanup. OpenCode assistant text merging uses a startsWith fast path so appended snapshots emit correct deltas.

Infrastructure: Git repository identity caches rev-parse roots separately (null on failure, retry-friendly TTL) so repeated workspace lookups avoid redundant Git calls. Native telemetry samples every 5s on AC when no live diagnostics subscribers (still 1s when subscribed), publishes health only when status/error changes, and the Rust history recorder only drops future-dated snapshots when the system clock moves backward.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fdcf91481addce8a8baa7529d77834c670277fb0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Cut idle CPU use and stop provider event leaks across server runtime

  • Reduces background telemetry sampling on AC power to 5s (1s when live subscribers exist) and publishes health only on actual state changes in NativeTelemetryClient
  • Skips ingestion of non-assistant_text content deltas in ProviderRuntimeIngestion and filters transient delta/update events from native provider logs in EventNdjsonLogger and AcpNativeLogging
  • Caches Git root resolution in RepositoryIdentityResolver with zero TTL on failure, and fixes resolveRepositoryIdentityCacheKey to return null instead of falling back to cwd
  • Fixes OpenCodeAssistantText delta computation in OpenCodeAdapter to emit only the true appended portion for strict appends
  • Bounds buffered incoming messages to 32 in CodexProtocol and AcpProtocol, rejects >32 concurrent Codex requests with CodexAppServerRequestError.overloaded, and interrupts in-flight handlers on termination
  • Risk: CodexProtocol now rejects excess concurrent requests with an overloaded error and stops processing after termination; RepositoryIdentityResolver returns null instead of cwd for failed root lookups, which may affect callers expecting a fallback path
Macroscope summarized fdcf914.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 3f8e2448-7614-4317-837b-9608c594ac05

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.3 KiB13.2 KiB−88 B (−0.6%)15.1 KiB✅
      CodexThread snapshot wire6.9 KiB6.9 KiB+11 B (+0.2%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.3 KiB−99 B (−1.5%)7.8 KiB✅
      CodexLive turn WebSocket decoded55.6 KiB55.5 KiB−88 B (−0.2%)66.4 KiB✅
      CodexLive turn messages119−2 (−18.2%)21✅
      ClaudeTotal thread wire13.3 KiB13.3 KiB−65 B (−0.5%)15.1 KiB✅
      ClaudeThread snapshot wire6.9 KiB6.9 KiB0 B (0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.4 KiB−65 B (−1.0%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded56.4 KiB56.4 KiB−44 B (−0.1%)66.4 KiB✅
      ClaudeLive turn messages1110−1 (−9.1%)21✅

      Baseline: c1c2d54 · PR result: fdcf914 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 109.4 KiB
      • Claude decoded thread snapshot: 110.1 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d647448cf2990d8ab0c084340d42f57b9db06490. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR changes several production execution and observability paths, including provider event ingestion, protocol buffering/concurrency, shutdown handling, and telemetry cadence. It also changes the normal AC background sampling default from 1 second to 5 seconds, making the impact broader than a mechanical performance optimization.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.