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

A pull's Files page answers a repeat view of a 40-file diff under 100 ms, and a test holds it #4215

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/4087-a-pull-s-files-page-answers-a-repeat-vie → main 1 commit fork

  • Merged. scout/4087-a-pull-s-files-page-answers-a-repeat-vie was merged into main as 5d88954.

Review

Sign in to review this change.
1 file changed +29 −17
test/pull-timing.test.ts +29 −17
@@ -103,24 +103,36 @@ async function filesApp(): Promise<number> {
103103 return Number(app![1]);
104104 }
105105
106 test("the Files page's cold first view of a fresh head: median of 3 under a ceiling beside its measurement", async () => {
107 const runs: number[] = [];
106 /** 40 files of 50 lines each, new content per `i` so each is a fresh head. */
107 async function commitHead(i: number): Promise<void> {
108 const done = await commitToBranch(app, owner, repoRow, {
109 branch: "topic",
110 message: `head ${i}`,
111 files: Array.from({ length: 40 }, (_, f) => ({
112 path: `d/f${f}.ts`,
113 content: Array.from({ length: 50 }, (_, l) => `export const v${i}_${f}_${l} = ${l};`).join("\n"),
114 })),
115 });
116 if (!done.ok) throw new Error(JSON.stringify(done.error));
117 }
118
119 // Measured over 3 runs of this test (40 files x 50 lines): the cold median of 3 was 125-135 ms
120 // (a single cold view up to 244 ms); the repeat median of 5 was 55 ms (single views 49-76 ms).
121 // 250 ms is ~2x the cold median; 100 ms is the issue's bar for a repeat view.
122 const COLD_MS = 250;
123
124 const median = (xs: number[]) => [...xs].sort((a, b) => a - b)[Math.floor(xs.length / 2)]!;
125
126 test("the Files page of a 40-file diff: cold median of 3 and repeat median of 5 stay under their ceilings", async () => {
127 const cold: number[] = [];
108128 for (let i = 0; i < 3; i++) {
109129 // A new head each time, so nothing rendered before is reused.
110 const done = await commitToBranch(app, owner, repoRow, {
111 branch: "topic",
112 message: `head ${i}`,
113 files: Array.from({ length: 20 }, (_, f) => ({
114 path: `d/f${f}.ts`,
115 content: Array.from({ length: 50 }, (_, l) => `export const v${i}_${f}_${l} = ${l};`).join("\n"),
116 })),
117 });
118 if (!done.ok) throw new Error(JSON.stringify(done.error));
119 runs.push(await filesApp());
130 await commitHead(i);
131 cold.push(await filesApp());
120132 }
121 const median = runs.sort((a, b) => a - b)[1]!;
122 // Measured over 10 runs of this file: the median of 3 was 76-95 ms (typically ~85), a single
123 // render up to 147 ms. 170 ms is 2x the typical median: loose enough for a slow machine, tight
124 // enough to catch a return to per-line highlighting.
125 expect(median).toBeLessThan(170);
133 // The head is unchanged now: every view reuses the rendered diff.
134 const repeat: number[] = [];
135 for (let i = 0; i < 5; i++) repeat.push(await filesApp());
136 expect(median(cold)).toBeLessThan(COLD_MS);
137 expect(median(repeat)).toBeLessThan(100);
126138 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs