Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): read quiet pull requests every five minutes #22073

Mergedjuliusmarmingemerged 1 commit intot3/pr-stack-etag-revalidation fromrefs/pull/22073/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Problem

Every T3 server re-reads every open pull request linked to an unsettled thread on each one-minute sync sweep (PullRequestSyncReactor). Telemetry from 44 servers sharing one GitHub account put getPullRequestSummary at about 5,300 GraphQL requests/hr, more than the 5,000/hr limit on its own, and about 98% of it came from the sweep.

Most of those pull requests weren't changing. On the busiest server, 104 open linked pull requests were read every minute; none had been updated in the last 30 minutes and only 4 in the last hour.

Fix

An open pull request whose host updatedAt is over 30 minutes old is read every 5 minutes instead of every sweep. One with recent activity keeps the one-minute cadence. Explicit refresh requests, watches, links without a snapshot, and runs that ran gh pr merge/close still read it at once, so the cost is that settlement of a quiet pull request merged elsewhere can lag by up to 5 minutes.

Top of a 2-PR stack on #22078.

Verification

  • New test: a quiet open pull request is read every five minutes until it changes, then every sweep again.
  • Two existing tests now use pull requests with recent activity, since they assumed every-minute reads of open pull requests. They test unchanged snapshots and rate-limit pauses.
  • vp test run apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts, plus lint and typecheck for apps/server.

Done by Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

    1. juliusmarminge added labelsmacroscope-review

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

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — The PR changes the server’s default pull-request synchronization cadence, deferring reads for quiet open pull requests from each minute to every five minutes and potentially delaying externally detected state changes. The behavior is covered by tests and remains localized, but the product-default change warrants human review.

      Notes:

      • All code in this push has already been reviewed. Approvability was decided on eligibility alone.

      No code changes detected at b597b18. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—5.0 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.9 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: b597b18 · 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: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

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

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Important

      Review skipped

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

      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 9e5a5dcf-985a-4020-b41f-c91cb6ca7409
      📥 Commits

      Reviewing files that changed from the base of the PR and between 6015b72ae234c2b078a7847f7d8ff7271a3412b2 and b597b1853bc282bf2c91a53c30663165d574df77.

      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: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 8cd85042-44b4-4d91-b217-189441729e7a
      📥 Commits

      Reviewing files that changed from the base of the PR and between 6327a639a6d3632f181899c425abb67acdbab6d5 and 707118f0d3ac483de8c74f598e4ae0ebc00c3839.

      📒 Files selected for processing: 4
      • apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
      • apps/server/src/orchestration-v2/PullRequestSyncReactor.ts
      • packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
      • packages/source-control-github/src/server/GitHubPullRequestApi.ts

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

      📝 Walkthrough

      The sync reactor now polls unchanged open pull requests on a five-minute cadence after 30 minutes. GitHub stack reads use credential-scoped ETag revalidation and reuse cached response bodies for HTTP 304 responses.

      Changes: Quiet pull-request synchronization

      Layer / File(s)Summary
      Quiet polling cadence
      apps/server/src/orchestration-v2/PullRequestSyncReactor.ts, apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
      Open pull requests unchanged for at least 30 minutes use a five-minute interval. Explicit refresh paths remain immediate. Tests cover the quiet cadence and update fixture timestamps.

      GitHub stack revalidation

      Layer / File(s)Summary
      Credential-scoped stack revalidation
      packages/source-control-github/src/server/GitHubPullRequestApi.ts, packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
      The initial stack request uses conditional REST reads. Cached bodies are reused on HTTP 304 responses, and validators are scoped to credentials. Tests cover revalidation and credential separation.

      Priority: ⬇️ Low

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Other

      Suggested reviewers: maria-rcks

      Merge Risk: ⚪ Minimal · up to 70711

      Quiet pull requests retain the intended polling cadence, and stack revalidation does not reuse cached responses across the inspected request contexts. The change is mergeable after normal checks.

      Pre-merge checks: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe description explains the problem, the fix, the behavior tradeoff, and focused verification. It does not include the required Scope and approval section or link a triaged issue or explicit maintain…Add a Scope and approval section with the triaged bug issue or discussion link and the explicit maintainer approval comment. If no prior approval exists, explain why this focused fix qualifies for an exemption.
      Passed Passed checks: 3 passed
      Check nameStatusExplanation
      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.
      Title checkPassedThe title clearly and concisely describes the main change: reducing polling frequency for quiet pull requests.
      Full details: Description check

      Explanation

      The description explains the problem, the fix, the behavior tradeoff, and focused verification. It does not include the required Scope and approval section or link a triaged issue or explicit maintainer approval.

      Resolution

      Add a Scope and approval section with the triaged bug issue or discussion link and the explicit maintainer approval comment. If no prior approval exists, explain why this focused fix qualifies for an exemption.

      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    5. juliusmarminge changed the title

    6. juliusmarminge merged this8dec2ff

    7. juliusmarminge closed this

Sign in to join this conversation.