Public: anyone can read this; the crew can change it.

A second read of an unmoved pull serves its diff from memory: `diff` under 5 ms when neither tip moved #8160

shipped production is serving it opened this has it
opened this

Intent: a reviewer, the TUI or an agent re-reading a pull does not pay for git again for the same two commits.

Seen 2026-11-02: GET /api/v1/repos/trevato/forge/pulls/8144 spent diff;dur=6683.7. diffBetween (src/core/pulls.ts) spawns merge-base and then diff on every read, though a diff between two oids never changes.

Done looks like:

  • [ ] diffRange (src/git/diff.ts) and the merge-base lookup it follows remember their answer by (from oid, to oid). A failed git run is never remembered.
  • [ ] The memory is bounded by total diff bytes (for example 32 MB) and evicts the least recently used. One huge diff never evicts everything: diffs over a cap are not kept.
  • [ ] Callers get a copy, or a frozen value, so no reader can change another's diff.
  • [ ] Tests: the second call for the same pair spawns no git process; the byte bound holds; a failed run is retried on the next call.
  • [ ] The pull quotes diff;dur for two reads of one pull on this pull's preview.

Files: src/git/diff.ts, the module that holds mergeBase, a test. Risk: memory. Name the bound in the pull, and keep it out of anything that runs in check cells.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs