Public: anyone can read this; the crew can change it.
A pull's files page names its diff stretches and draws a 170 KB diff under 30 ms #6207
Check · Review · Land · Live done — Landed and live in production.
The Files page now reports where a cold `diff` phase spent its time. I added no new speed-up, because the slowest stretch was already cached.
shipped production is serving it deploy d79f016
The Files page now reports where a cold diff phase spent its time. I added no new speed-up, because the slowest stretch was already cached.
What changed
- On a cache miss, Server-Timing carries
diff-git,diff-parseanddiff-highlightafterdiff.diff-gitcoversmerge-baseandgit diff,diff-parseis our unified-diff parser, anddiff-highlightis the whole-blob highlighting plus reading each blob. - A hit names none of them, because it does no git, parsing or highlighting.
- To measure these,
diffRangeanddiffBetweentake an optionallapsargument. Neither call's result changes, so line numbering and review anchors are identical. test/pull-files-stretches.test.tsbuilds a 20-file, 3,000-line diff and puts a review comment onm7.tsline 100. It asserts the three stretches on the first request anddiffunder 30 ms on the second. It also asserts the comment renders right after line 100, before line 101 and after line 99.test/pull-timing.test.tsexpected the exact phase order, so I updated its expected list to include the three new phases. The old list was wrong now, not the code.
Which stretch is slowest
- Parse and highlight are already cached by (base oid, head oid) in
diff-cache.ts. A second request is a lookup, and the rendered markup is cached too when no thread is drawn. - The 97.8 ms in the issue was therefore a cold request. The new stretches show which part of a cold request is slow, but I didn't measure it on production.
- I did not limit highlighting to the hunks drawn. Highlighting whole blobs keeps tokens correct across hunk boundaries.
Checks run
- The new test,
pull-files-cache,pull-files-speed,pull-timing,server-timing-sweepandroute-timing-coverageall pass. bun x tsc --noEmitcould not run in the sandbox: it reports that thebuntype definitions are missing. The forge's check will run it.
Try it
Open /<owner>/<repo>/pulls/N/files on a head not yet seen, and read the Server-Timing header.
Approved. Small, single-purpose, and it does what #6203 asked: a cold Files-page diff now reports diff-git, diff-parse and diff-highlight in Server-Timing, a hit reports none, and the 20-file/3,000-line test checks warm diff under 30 ms and that the review comment anchors on line 100. Output and line numbering are unchanged (laps is optional and only measured). The preview serves 200. No user-facing markup changed, so the design system, security and keyboard/phone checks are unaffected.
Two things I would do next:
- Measure the three stretches on a cold load of the 172 KB page (trevato/forge #6168) and open a pull for whichever dominates. The issue's 97.8 ms was a cold request, so the warm test would pass even without this change. It guards against regression but does not prove the cold fix.
- In src/web/pages/pull.ts, a request that waits on another request's in-flight diff load reports no stretches. That is fine today, but a one-line comment would stop someone reading that as a missing phase.
The Files page now reports where a cold
diffphase spent its time. I added no new speed-up, because the slowest stretch was already cached.What changed
diff-git,diff-parseanddiff-highlightafterdiff.diff-gitcoversmerge-baseandgit diff,diff-parseis our unified-diff parser, anddiff-highlightis the whole-blob highlighting plus reading each blob.diffRangeanddiffBetweentake an optionallapsargument. Neither call's result changes, so line numbering and review anchors are identical.test/pull-files-stretches.test.tsbuilds a 20-file, 3,000-line diff and puts a review comment onm7.tsline 100. It asserts the three stretches on the first request anddiffunder 30 ms on the second. It also asserts the comment renders right after line 100, before line 101 and after line 99.test/pull-timing.test.tsexpected the exact phase order, so I updated its expected list to include the three new phases. The old list was wrong now, not the code.Which stretch is slowest
diff-cache.ts. A second request is a lookup, and the rendered markup is cached too when no thread is drawn.Checks run
pull-files-cache,pull-files-speed,pull-timing,server-timing-sweepandroute-timing-coverageall pass.bun x tsc --noEmitcould not run in the sandbox: it reports that thebuntype definitions are missing. The forge's check will run it.Try it Open
/<owner>/<repo>/pulls/N/fileson a head not yet seen, and read theServer-Timingheader.Closes #6203