Skip to content

Commit 0a1c2fa

Browse files
committed
ci(studio): gate only the open journey's counts; scroll counts follow runner speed
1 parent 655eb7e commit 0a1c2fa

3 files changed

Lines changed: 6 additions & 92 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,6 @@ jobs:
812812
else
813813
DEFAULT_STATUS=1
814814
fi
815-
COUNT_STATUS=0
816-
node packages/studio/tests/e2e/perf-ratchet.mjs check \
817-
packages/studio/tests/e2e/perf-ceilings.json timeline-scroll \
818-
/tmp/timeline-gate-default.json /tmp/base-perf-ceilings.json || COUNT_STATUS=$?
819815
stop_server
820816
821817
NODE_ENV=production \
@@ -840,11 +836,10 @@ jobs:
840836
echo "### Timeline viewport gate"
841837
echo "- Default arm exit: ${DEFAULT_STATUS}"
842838
echo "- Explicitly disabled arm exit: ${DISABLED_STATUS}"
843-
echo "- Work per scroll step against perf-ceilings.json exit: ${COUNT_STATUS}"
844839
} >> "$GITHUB_STEP_SUMMARY"
845840
846-
if (( DEFAULT_STATUS != 0 || DISABLED_STATUS != 0 || COUNT_STATUS != 0 )); then
847-
echo "FAIL: default=${DEFAULT_STATUS}, disabled=${DISABLED_STATUS}, counts=${COUNT_STATUS}"
841+
if (( DEFAULT_STATUS != 0 || DISABLED_STATUS != 0 )); then
842+
echo "FAIL: default=${DEFAULT_STATUS}, disabled=${DISABLED_STATUS}"
848843
exit 1
849844
fi
850845
- name: Count the work of opening a film in Studio

‎packages/studio/tests/e2e/perf-ceilings.json‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,5 @@
77
"total.requests.document": 2,
88
"total.requests.thumbnail": 20
99
}
10-
},
11-
"timeline-scroll": {
12-
"browser": "153",
13-
"counts": {
14-
"reactCommitsPerScrollStep": 1
15-
}
1610
}
1711
}

‎packages/studio/tests/e2e/timeline-virtualization.mjs‎

Lines changed: 4 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import { platform, arch } from "node:os";
2525
import puppeteer from "puppeteer-core";
2626
import { resolveChromeExecutable } from "./chrome-executable.mjs";
27-
import { diffCounts, startWorkCounters } from "./perf-counters.mjs";
2827

2928
const STUDIO_URL = process.env.STUDIO_URL;
3029
const PROFILE = process.env.TIMELINE_PROFILE || "dense-short";
@@ -168,62 +167,6 @@ async function collectRun(page, injectedLongTaskMs = 0) {
168167
}, injectedLongTaskMs);
169168
}
170169

171-
const WORK_COUNT_PASSES = 3;
172-
// Ten times the timeline's scroll-settle delay (TIMELINE_SCROLL_SETTLE_MS).
173-
const WORK_QUIET_MS = 1_000;
174-
const SCROLL_WORK_STEPS = [0.25, 0.5, 0.75, 1, 0.5, 0];
175-
176-
/**
177-
* Work per scroll step, counted apart from the timed runs. Each step waits until no React commit
178-
* has landed for WORK_QUIET_MS before the next, so a slower machine waits longer rather than
179-
* letting a step's late work fall into the next one.
180-
*/
181-
async function countScrollWork(page, workCounters) {
182-
const passes = [];
183-
for (let pass = 0; pass < WORK_COUNT_PASSES; pass += 1) {
184-
await page.evaluate(scrollStepsUntilQuiet, [0], WORK_QUIET_MS);
185-
const before = await workCounters.read();
186-
const steps = await page.evaluate(scrollStepsUntilQuiet, SCROLL_WORK_STEPS, WORK_QUIET_MS);
187-
const work = diffCounts(await workCounters.read(), before);
188-
passes.push(
189-
Object.fromEntries(
190-
["reactCommits", "styleRecalcs", "layouts"].map((counter) => [
191-
`${counter}PerScrollStep`,
192-
Math.round((work[counter] / steps) * 100) / 100,
193-
]),
194-
),
195-
);
196-
}
197-
return passes;
198-
}
199-
200-
/** In the page: scroll to each ratio and wait for quiet; returns how many steps moved. */
201-
async function scrollStepsUntilQuiet(ratios, quietMs) {
202-
const root = document.querySelector('[aria-label="Timeline track view"]');
203-
const scroller = root?.querySelector("[data-timeline-scroll-viewport]");
204-
if (!(scroller instanceof HTMLElement)) throw new Error("Timeline scroller not mounted");
205-
const commits = () => window.__hfWorkCounts?.reactCommits ?? 0;
206-
const nextFrame = () => new Promise((resolve) => requestAnimationFrame(resolve));
207-
let moved = 0;
208-
for (const ratio of ratios) {
209-
const left = Math.round((scroller.scrollWidth - scroller.clientWidth) * ratio);
210-
const top = Math.round((scroller.scrollHeight - scroller.clientHeight) * ratio);
211-
if (scroller.scrollLeft !== left || scroller.scrollTop !== top) moved += 1;
212-
scroller.scrollLeft = left;
213-
scroller.scrollTop = top;
214-
let seen = commits();
215-
let quietSince = performance.now();
216-
const deadline = quietSince + 30_000;
217-
while (performance.now() - quietSince < quietMs) {
218-
await nextFrame();
219-
if (commits() !== seen) [seen, quietSince] = [commits(), performance.now()];
220-
if (performance.now() > deadline)
221-
throw new Error("The timeline never went quiet after a scroll");
222-
}
223-
}
224-
return moved;
225-
}
226-
227170
async function assertLongTaskCapture(browser, longTaskLimitMs, scrollSamplesPerRun) {
228171
const page = await browser.newPage();
229172
const injectedDurationMs = longTaskLimitMs + 25;
@@ -312,8 +255,6 @@ try {
312255
deviceScaleFactor: TIER === "high-dpr" ? 2 : 1,
313256
});
314257
const client = await page.createCDPSession();
315-
// Page-activity observers stay off: they would run inside the timed scroll.
316-
const workCounters = await startWorkCounters(browser, page, { pageActivity: false });
317258
if (TIER === "low-resource") {
318259
await client.send("Emulation.setCPUThrottlingRate", { rate: 4 });
319260
}
@@ -392,8 +333,6 @@ try {
392333
run.passed = run.responsivenessPassed && run.timelineMounted && run.domSizePassed !== false;
393334
}
394335

395-
const workPasses = await countScrollWork(page, workCounters);
396-
397336
await page.evaluate(() => window.__studioTest.resetTimelinePerformanceFixture());
398337
await page.waitForFunction(
399338
() => document.querySelector('[aria-label="Timeline track view"]') === null,
@@ -416,23 +355,7 @@ try {
416355
? "approved"
417356
: "rejected",
418357
};
419-
// The median pass per counter; perf-ratchet.mjs holds the gated ones under perf-ceilings.json.
420-
const workCounts = Object.fromEntries(
421-
Object.keys(workPasses[0]).map((counter) => {
422-
const values = workPasses.map((pass) => pass[counter]);
423-
// NaN sorts unpredictably, so one pass missing a counter must not hide behind the median.
424-
const median = values.every(Number.isFinite) ? percentile(values, 0.5) : Number.NaN;
425-
return [counter, median];
426-
}),
427-
);
428-
const interactionP95Ms = percentile(
429-
runs.map((run) => run.interactionP95Ms),
430-
0.95,
431-
);
432358
const evidence = {
433-
journey: "timeline-scroll",
434-
workCounts,
435-
workPasses,
436359
environment: {
437360
browser: version,
438361
executablePath,
@@ -462,9 +385,11 @@ try {
462385
},
463386
directScrollGate,
464387
runs,
465-
wallMs: interactionP95Ms,
466388
aggregate: {
467-
interactionP95Ms,
389+
interactionP95Ms: percentile(
390+
runs.map((run) => run.interactionP95Ms),
391+
0.95,
392+
),
468393
frameIntervalP95Ms: percentile(
469394
runs.map((run) => run.frameIntervalP95Ms),
470395
0.95,

0 commit comments

Comments
 (0)