perf(server): skip no-op settlement decisions #27897
main fromrefs/pull/27897/head·merged by maria-rcks View on GitHubPerformance: settlement sweep 60.826 → 5.187 ms; settings reads reduced from 8,002 to 2 for 4,000 synthetic threads.
A settlement sweep currently performs two no-op settings/decision passes for each recent thread with no branch or PR reference. With 4,000 such threads, the actual service performs 8,002 settings reads per sweep even though no thread can settle and no Git lookup is useful.
Prefilter no-op decisions using the sweep's settings and exclude branchless threads without PR references from the subsequent host-lookup pass. Any actual settlement still reads current settings before deciding to dispatch. The existing settings-change subscription requeues skipped candidates when configuration changes.
The actual service make/start/drain benchmark (mocked projections/settings/Git/filesystem, recent synthetic candidates, 4 warmups + 15 alternating samples) reduced settings reads from 8,002 to 2. Mac medians were 60.826 → 5.187 ms in the recorded paired run. These are service orchestration timings with cached/mock settings, not SQL reads, full-app latency, or disk-write measurements; other host workloads affect wall-clock samples. Reproducer and every raw sample.
The new regression fails on baseline (66 reads for 32 threads instead of 2), then passes after the fix. It checks no unexpected dispatch/Git lookup and immediately reevaluates skipped threads after a settings change. All 31 focused settlement tests pass, including disabling settlement during a sweep, per-project opt-in, PR outcomes and background work. vp run check:changed --concurrency 1 passes on this standalone branch; CI still owns full suites/build. No live database, product defaults or provider configuration changed. This is a small focused performance fix for redundant work in an existing background operation. Reviewed solo per the user's request.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
verified unchanged head
a315fe7b19ea0c52cfd7dc9059a6a16916c6e9d1on this linux vm. baseline wasgithub/mainat54c5f25249in a separate worktree. each checkout ranvp iand one background dev server at a time. playwright used the repo dependency and/usr/bin/google-chrome.created real git repositories, added projects through the web ui, and submitted real codex
gpt-6.1-solturns through the composer and local provider proxy. one project had a detached head, producing a thread withbranch: nulland no pr reference. no mock provider, fixtures, or demo data.short server transcript, from temporary observation-only counters around the real sweep's settings reads:
main: completed branchless codex turn -> thread sweep candidates=1 branch=null settingsReads=3 pr: real follow-up in the same branchless thread -> thread sweep candidates=1 branch=null settingsReads=1 both: recent thread remains active; codex response rendered in clientthe counters were removed before functional verification and checks. the checkout is clean. these are observed settings-read counts, not a claim about full-app latency or the synthetic 4,000-thread benchmark.
on the unmodified pr head, advanced only the dev server process clock by two days using libfaketime, without editing stored timestamps. with the same app-created conversations, changing threads settings from 3 days to 1 immediately auto-settled the inactive branchless thread and an unpinned branched thread. a pinned thread stayed active. sending a new message to the settled branchless thread reopened it, showed working, completed another real codex turn, and left it active.


inspected the captures and verified uploaded video playback and seeking in t3's player.
blacksmith checks passed: all 31 settlement tests, then
vp run check:changed 78f1ba8285898d50af82a49c98364197d330db6a(format, lint, both knip passes, graphql, typecheck of 3 packages, and 32 tests). the explicit parent ref was needed because the remote source snapshot initially had no main merge base. the pr reported 20 successful and 6 skipped ci checks, with no failures.Not verified#
native ios/android, the electron shell, macos/windows, remote/relay/tunnel connections, other providers, and real external pr merge/close settlement were not exercised. no pr was merged or closed for this verification. large-history latency and the author's synthetic benchmark numbers were not measured.
maria-rcks merged thisdabab45
maria-rcks closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review.
1dd0625b-39fc-44ae-8848-0412122adf13Reviewing files that changed from the base of the PR and between d2d1e4f50ef856f940d91858915368500657b0b7 and a315fe7b19ea0c52cfd7dc9059a6a16916c6e9d1.
apps/server/src/orchestration-v2/ThreadSettlementService.test.tsapps/server/src/orchestration-v2/ThreadSettlementService.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Walkthrough
The settlement sweep now checks project-specific settings before calling
settleThreadand excludes lookup candidates without a branch or pull-request identifier. A worker test covers settings reads and settlement outcomes for 32 branchless threads.Changes: Settlement sweep
apps/server/src/orchestration-v2/ThreadSettlementService.ts,apps/server/src/orchestration-v2/ThreadSettlementService.test.tssettleThread. The test harness counts settings reads, and a worker test checks behavior for 32 branchless threads at two settlement thresholds.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Refactor
Possibly related issues
pingdotgg/t3code issue 19657: Both concern unnecessary settlement-sweep work, but this change does not exclude subagent threads by lineage.pingdotgg/t3code issue 24098: Both concern settlement-sweep branch and pull-request work, but this change does not alter git-state caching or terminal-branch lookups.pingdotgg/t3code issue 27696: Both concern background work from finished subagent threads, but this change does not exclude finished subagents or bound pull-request polling.pingdotgg/t3code issue 21888: Both involveThreadSettlementServiceV2lookups, but this change does not alter Azure CLI process creation, token reuse, or other polling paths.Suggested reviewers:
juliusmarminge,macroscopeappMerge Risk:
Minimal · up to
a315fThe sweep avoids redundant work without an identified merge-blocking issue.
Pre-merge checks:
4
Full details: Description check
Explanation
The description explains the problem, change, scope, performance results, regression coverage, focused test results, and verification limits. It does not use the template headings, but it includes the required information and justifies the focused fix without a linked issue.
Finishing Touches
Generate unit tests (beta)