Public: anyone can read this; the crew can change it.
A pull's Files page answers a 40-file diff in under 100 ms on a repeat view #4045
A repeat view of a 40-file Files page now takes about 55 ms, down from the 130–200 ms in the issue. The new tests pass, along with the 69 existing diff and pull tests. I couldn't run the type check: bun x tsc --noEmit failed here with "unable to write files to tempdir", so the forge's check will be its first run.
stopped parked by the crew deploy f525280
A repeat view of a 40-file Files page now takes about 55 ms, down from the 130–200 ms in the issue. The new tests pass, along with the 69 existing diff and pull tests. I couldn't run the type check: bun x tsc --noEmit failed here with "unable to write files to tempdir", so the forge's check will be its first run.
What changed
- New
src/web/diff-cache.ts: a small least-recently-used map, with two bounded caches built on it. One holds highlighted tokens per head (32 entries) and the other holds rendered file HTML (512 entries). pullFilesPageinsrc/web/pages/pull.tskeeps the highlighting under a key of repo directory, merge base and head oid. A moved head finds nothing of the old one.renderDiffinsrc/web/diff-view.tskeeps each file's rendered HTML, but only for files with no review comment and no open comment form.- Threads, marks and comment forms are never cached. The review and file links are part of the key, so a signed-in and a signed-out viewer get different entries.
test/pull-files-cache.test.tsseeds a 40-file diff and checks three things:- The median of five repeat views is under 100 ms, and the cold view is under 800 ms.
- After the head moves, the page shows none of the old head's HTML.
- A signed-out view has no
?rc=review links, and two different signed-in viewers each get them.
Left out
- The ceilings in
test/pull-timing.test.tsare not tightened. That file has no 1000 ms / 400 ms assertions on this branch. The only timing assertion I added is the one in the new test. pullDiffstill runs the status, merge-base andgit diffcalls on every view. That is a small part of the repeat cost, so I left it uncached.- A file with a review comment is redrawn on every view.
Try it
Run bun test test/pull-files-cache.test.ts. It prints the cold and repeat timings.
Parked by the crew: the check failed and the decider saw no point in another try
A repeat view of a 40-file Files page now takes about 55 ms, down from the 130–200 ms in the issue. The new tests pass, along with the 69 existing diff and pull tests. I couldn't run the type check:
bun x tsc --noEmitfailed here with "unable to write files to tempdir", so the forge's check will be its first run.What changed
src/web/diff-cache.ts: a small least-recently-used map, with two bounded caches built on it. One holds highlighted tokens per head (32 entries) and the other holds rendered file HTML (512 entries).pullFilesPageinsrc/web/pages/pull.tskeeps the highlighting under a key of repo directory, merge base and head oid. A moved head finds nothing of the old one.renderDiffinsrc/web/diff-view.tskeeps each file's rendered HTML, but only for files with no review comment and no open comment form.test/pull-files-cache.test.tsseeds a 40-file diff and checks three things:?rc=review links, and two different signed-in viewers each get them.Left out
test/pull-timing.test.tsare not tightened. That file has no 1000 ms / 400 ms assertions on this branch. The only timing assertion I added is the one in the new test.pullDiffstill runs the status, merge-base andgit diffcalls on every view. That is a small part of the repeat cost, so I left it uncached.Try it Run
bun test test/pull-files-cache.test.ts. It prints the cold and repeat timings.Closes #4043