Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(observability): stop writing empty spans on spawns, projected events, and idle polls #13756

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/13756/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

A few leaf spans carried no data but made up 26-34% of all spans in a steady-state bench (458 of 1,338 per minute). They fill the trace ring faster, so it keeps less real history, and they cost time on hot paths: every spawn and every projected event. An idle server also wrote a PortScanner span every 3 s with nothing to scan.

Fix

  • createTrace2Monitor runs on every git spawn and returns at once unless a caller wants hook progress. It is now Effect.fnUntraced. Its errors still fail the runGitCommand span.
  • shell.resolveSpawnCommand and the two processRunner.collectText calls run on every processRunner spawn (lsof, gh, VCS, providers). They are now untraced. Their errors still fail the runProcessCore span.
  • projectEventDeferred skips applyAttachmentSideEffects when there is no attachment cleanup, so most events write no cleanup span.
  • The PortScanner poll checks retainCount before the pollTick span starts.

Trade-off: on Windows, the PATH lookup time in resolveSpawnCommand now counts toward the parent span, not a span of its own.

Verification

  • New tests: projecting project.created writes no applyAttachmentSideEffects span and thread.deleted writes one. An idle PortScanner writes no pollTick span over 15 s, and a retain writes one. Both tests fail with the fix reverted.
  • vp test run for the PortScanner, ProjectionPipeline, processRunner, GitVcsDriverCore, and shared shell tests. Lint, fmt, and typecheck for t3 and @t3tools/shared.
  • #9824 changes the same pollTick retainCount gate in PortScanner.ts and also detaches the poll fiber from the PortDiscovery.make span. Whichever lands second needs a small rebase.

Made by Claude Opus 5.5 (1M context) in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Preview port discovery now skips scheduled polling when no clients are using the scanner, reducing unnecessary background activity.
    • Attachment cleanup is now scheduled only when an event records deleted threads or pruned attachments. Deleting a thread continues to trigger the cleanup process.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. 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.5 KiB13.5 KiB−14 B (−0.1%)15.1 KiB✅
      CodexThread snapshot wire7.1 KiB7.1 KiB−6 B (−0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB−8 B (−0.1%)7.8 KiB✅
      CodexLive turn WebSocket decoded56.2 KiB56.2 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages990 (0.0%)21✅
      ClaudeTotal thread wire13.5 KiB13.5 KiB−14 B (−0.1%)15.1 KiB✅
      ClaudeThread snapshot wire7.1 KiB7.1 KiB+5 B (+0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB−19 B (−0.3%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.0 KiB57.0 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages990 (0.0%)21✅

      Baseline: 92f0af2 · PR result: 51569b4 · 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: 114.0 KiB
      • Claude decoded thread snapshot: 114.7 KiB

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

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

      Approvability

      Verdict: Approved at 32a8a44

      Macroscope's review found this PR approvable — This is a small, well-scoped observability/performance cleanup that suppresses empty spans while preserving cleanup, polling, process execution, Git hook handling, and Windows command resolution. Added tests verify the changed span behavior, with no product-default, schema, infrastructure, or static-analysis override changes.

      No code changes detected at 51569b4. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

      Important

      Review skipped

      Review was skipped as selected files did not have any reviewable changes.

      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Team

      Run ID: cd87d6e1-19b7-413a-a1da-15c820a17743

      📥 Commits

      Reviewing files that changed from the base of the PR and between 32a8a4428ef982572c1725a11d235691c7baecba and 51569b4326802018342e95eaff6b29dbd3a67851.

      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

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Team

      Run ID: 5bc6be58-2fa9-4427-8924-b797a58a4f51

      📥 Commits

      Reviewing files that changed from the base of the PR and between a21b42cec478b093cdc50cc2105b5368ea8b3546 and 32a8a4428ef982572c1725a11d235691c7baecba.

      📒 Files selected for processing (7)
      • apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
      • apps/server/src/orchestration/Layers/ProjectionPipeline.ts
      • apps/server/src/preview/PortScanner.test.ts
      • apps/server/src/preview/PortScanner.ts
      • apps/server/src/processRunner.ts
      • apps/server/src/vcs/GitVcsDriverCore.ts
      • packages/shared/src/shell.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The changes conditionally run attachment cleanup, skip scheduled port polling when no client retains the scanner, and switch three functions to untraced effect wrappers.

      Changes

      Tracing and scheduled work

      Layer / File(s)Summary
      Conditional attachment cleanup
      apps/server/src/orchestration/Layers/ProjectionPipeline.ts, apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
      projectEventDeferred returns the cleanup effect only when attachment side effects exist. The test checks spans for project creation and thread deletion.
      Polling only while retained
      apps/server/src/preview/PortScanner.ts, apps/server/src/preview/PortScanner.test.ts
      The scheduled wrapper calls pollTick only when the scanner has a retained client. The test checks polling spans before and after retention.
      Untraced effect wrappers
      apps/server/src/processRunner.ts, apps/server/src/vcs/GitVcsDriverCore.ts, packages/shared/src/shell.ts
      collectText, createTrace2Monitor, and resolveSpawnCommand now use Effect.fnUntraced. Their existing processing behavior is unchanged.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Other

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 32a8a

      The changes reduce empty and idle spans while preserving cleanup, retained polling, and error handling. No actionable merge risk was established.

      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the main observability performance changes: removing empty spans from spawns, projected events, and idle polls.
      Description check✅ PassedThe description explains what changed, why it changed, the trade-off, and verification steps. The UI section is not applicable. The checklist section is omitted, but the description is otherwise compl…
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 7…
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.

Sign in to join this conversation.