Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): release oversized pull request diff cache entries #12523

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/12523/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Large pull-request diff slices remained strongly referenced by both the normal diff cache and its stale fallback after the request finished. Those caches admitted up to 128 results without accounting for patch size.

Skip retention when a patch exceeds 512 KiB of estimated UTF-16 storage. Return the complete patch and pagination metadata unchanged, retain caching for small results, and guard invalidation against removing a replacement entry. Each persistent cache is consequently limited to 64 MiB of patch text. Repeated server requests for oversized slices fetch them again.

Before/after evidence against this PR's main base: an isolated GC check through the actual service read 16 synthetic diff results totaling 8 MiB. The base retained all 16 after GC (54 MiB heap); this revision retained zero (46 MiB heap). This demonstrates this retention defect; it does not establish the retaining root of the separately observed 3.86 GiB backend crash.

Validation: 165 focused PullRequestService tests passed, including large regular, paginated, and commit slices and small replacements; server package typecheck, scoped lint, formatting, and diff checks passed. The shared service applies to all source-control providers and web, desktop, and mobile connections without a contract change.

Prepared with Codex.


Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Improved diff caching behavior for very large responses.
    • Large diffs are still returned when requested but are no longer retained in the cache.
    • Smaller diff responses continue to be cached and reused.
    • Updated viewed-file handling to preserve cached diffs when file marks are invalidated.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

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

      All clear

      Posted via Macroscope — Effect Service Conventions
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.5 KiB13.5 KiB+2 B (+0.0%)15.1 KiB✅
      CodexThread snapshot wire7.1 KiB7.1 KiB+7 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB−5 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−4 B (−0.0%)15.1 KiB✅
      ClaudeThread snapshot wire7.1 KiB7.1 KiB−4 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.4 KiB6.4 KiB0 B (0.0%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.0 KiB57.0 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages990 (0.0%)21✅

      Baseline: e74c668 · PR result: 04bbab1 · 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: 113.9 KiB
      • Claude decoded thread snapshot: 114.6 KiB

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

    4. Approvability

      Verdict: Approved at 04bbab1

      Macroscope's review found this PR approvable — This is a small, isolated cache-retention fix that preserves complete diff responses and existing small-diff caching while preventing oversized patches from remaining in either cache. Focused tests cover regular, paginated, and commit diff paths, including replacement behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Review Change StackReview Change Stack

      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: 69db5a83-0161-4829-8ccc-67d7a3ea9c26

      📥 Commits

      Reviewing files that changed from the base of the PR and between e74c668d786ffc14f40a9540cd3aede02ba5d62e and 04bbab1d8219ad93be0f3aa130fb2a042301fd06.

      📒 Files selected for processing (2)
      • apps/server/src/pullRequest/PullRequestService.test.ts
      • apps/server/src/pullRequest/PullRequestService.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


      📝 Walkthrough

      Walkthrough

      The pull request limits cached diffs to 512 KiB of UTF-16 storage. Oversized diffs are returned but not retained. Matching oversized cached values are invalidated, and tests cover repeated large responses and later small cached responses.

      Changes

      Diff cache handling

      Layer / File(s)Summary
      Cache size policy
      apps/server/src/pullRequest/PullRequestService.ts
      The service permits caching only diffs within the 512 KiB UTF-16 limit and skips oversized values during diff recording.
      Oversized read behavior
      apps/server/src/pullRequest/PullRequestService.ts, apps/server/src/pullRequest/PullRequestService.test.ts
      Diff reads invalidate matching oversized cached values before stale-diff handling. Tests cover repeated large responses, later small-response reuse, and cached diffs remaining after file-mark invalidation.

      Priority: ⬇️ Low

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

      Change: Bug fix

      Suggested reviewers: maria-rcks

      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the primary change: releasing oversized pull-request diff cache entries.
      Description check✅ PassedThe description explains the problem, the caching change, expected behavior, validation, and scope. It does not use the template headings or checklist, but it provides the required information and is …
      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 2…
      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.
    6. juliusmarminge merged thiscb3d95c

    7. juliusmarminge closed this

Sign in to join this conversation.