Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): skip no-op settlement decisions #27897

Mergedomar7550(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/27897/headmerged by maria-rcks View on GitHub

Performance: 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

    2. Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between d2d1e4f50ef856f940d91858915368500657b0b7 and a315fe7b19ea0c52cfd7dc9059a6a16916c6e9d1.

      Files selected for processing: 2
      • apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
      • apps/server/src/orchestration-v2/ThreadSettlementService.ts

      Included 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 settleThread and 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

      Layer / File(s)Summary
      Candidate filtering and settlement checks
      apps/server/src/orchestration-v2/ThreadSettlementService.ts, apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
      The sweep excludes lookup candidates without a branch, linked pull request, or branch pull request. It checks project-specific settings before calling settleThread. 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 involve ThreadSettlementServiceV2 lookups, but this change does not alter Azure CLI process creation, token reuse, or other polling paths.

      Suggested reviewers: juliusmarminge, macroscopeapp

      Merge Risk: Minimal · up to a315f

      The sweep avoids redundant work without an identified merge-blocking issue.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the server performance fix: skipping no-op settlement decisions. It is concise and specific.
      Description checkPassedThe 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…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      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)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
    3. maria-rckscommented

      Note

      Written by gpt-6.1-sol on behalf of Maria

      Verified in a real dev environment

      verified unchanged head a315fe7b19ea0c52cfd7dc9059a6a16916c6e9d1 on this linux vm. baseline was github/main at 54c5f25249 in a separate worktree. each checkout ran vp i and 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-sol turns through the composer and local provider proxy. one project had a detached head, producing a thread with branch: null and 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 client

      the 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.

      inactive branchless thread settled while the pinned thread remains active

      sending a message reopens the settled thread and completes a real codex turn

      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.

    4. maria-rcks merged thisdabab45

    5. maria-rcks closed this

Sign in to join this conversation.