perf(observability): stop writing empty spans on spawns, projected events, and idle polls #13756
main fromrefs/pull/13756/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubA 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#
createTrace2Monitorruns on every git spawn and returns at once unless a caller wants hook progress. It is nowEffect.fnUntraced. Its errors still fail therunGitCommandspan.shell.resolveSpawnCommandand the twoprocessRunner.collectTextcalls run on every processRunner spawn (lsof, gh, VCS, providers). They are now untraced. Their errors still fail therunProcessCorespan.projectEventDeferredskipsapplyAttachmentSideEffectswhen there is no attachment cleanup, so most events write no cleanup span.- The PortScanner poll checks
retainCountbefore thepollTickspan 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.createdwrites noapplyAttachmentSideEffectsspan andthread.deletedwrites one. An idle PortScanner writes nopollTickspan over 15 s, and a retain writes one. Both tests fail with the fix reverted. vp test runfor the PortScanner, ProjectionPipeline, processRunner, GitVcsDriverCore, and shared shell tests. Lint, fmt, and typecheck fort3and@t3tools/shared.
Related#
- #9824 changes the same
pollTickretainCount gate inPortScanner.tsand also detaches the poll fiber from thePortDiscovery.makespan. 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved at
32a8a44Macroscope'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
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).51569b4. Prior analysis still applies.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_statustofalsein 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.tsapps/server/src/orchestration/Layers/ProjectionPipeline.tsapps/server/src/preview/PortScanner.test.tsapps/server/src/preview/PortScanner.tsapps/server/src/processRunner.tsapps/server/src/vcs/GitVcsDriverCore.tspackages/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.tsprojectEventDeferredreturns 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.tsThe scheduled wrapper calls pollTickonly 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.tscollectText,createTrace2Monitor, andresolveSpawnCommandnow useEffect.fnUntraced. Their existing processing behavior is unchanged.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Other
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
32a8aThe 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 name Status Explanation Title check ✅ Passed The title clearly summarizes the main observability performance changes: removing empty spans from spawns, projected events, and idle polls. Description check ✅ Passed The 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 ✅ Passed No 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 ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check 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.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
92f0af2· PR result:51569b4· Source CI: successScenario 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.