test(benchmarks): compare on anon memory, retry pre-hydration login clicks

Two fixes found by running the harness against a real pair of images:

Login submitted before the form hydrated, so the click was a no-op that
looked identical to bad credentials. Load the page at networkidle and
retry the submit, surfacing any page alert if all attempts fail — the
same race already handled for the onboarding restore toggle.

memory.current counts reclaimable page cache, which moved the "same"
baseline between 192 and 261 MiB across runs. Anonymous memory is now
the headline metric (idle was 144 MiB anon vs 77 MiB of page cache), so
an A/B is not decided by unrelated disk I/O.
This commit is contained in:
Thomas Camlong committed 2026-08-09 00:44:50 +02:00
1 parent 6363d96a1b
commit fb80b3882d
3 files changed
+67 -18

No files matched your search

+22 -4
View File
@@ -14,18 +14,20 @@ import {
const snapshot = ({
current = 300 * 1024 * 1024,
peak = 400 * 1024 * 1024,
anon = 250_000_000,
processes = ["1|0|4096|nginx|2048", "20|1|204800|node|180000", "30|1|8192|redis-server|4096"],
redis = true,
}: {
current?: number;
peak?: number;
anon?: number;
processes?: string[];
redis?: boolean;
} = {}) =>
[
`memory_current=${current}`,
`memory_peak=${peak}`,
"cgroup_anon=250000000",
`cgroup_anon=${anon}`,
"cgroup_file=50000000",
...processes.map((process) => `process=${process}`),
...(redis ? ["redis_used_memory=1048576", "redis_used_memory_peak=2097152"] : []),
@@ -136,8 +138,13 @@ describe("getGrowthBytesPerHour", () => {
});
describe("summarizeStress", () => {
/** anon defaults to current so the fixture's two metrics move together. */
const build = (name: string, currentMiB: number, elapsedMs: number) =>
parseStressSnapshot(name, elapsedMs, snapshot({ current: currentMiB * 1024 * 1024, peak: 900 * 1024 * 1024 }));
parseStressSnapshot(
name,
elapsedMs,
snapshot({ current: currentMiB * 1024 * 1024, anon: currentMiB * 1024 * 1024, peak: 900 * 1024 * 1024 }),
);
it("surfaces the headline lifecycle numbers", () => {
const summary = summarizeStress([
@@ -146,6 +153,8 @@ describe("summarizeStress", () => {
build("05-after-stress", 600, 120_000),
]);
expect(summary.headline.bootIdleAnonMiB).toBe(200);
expect(summary.headline.boardLoadedAnonMiB).toBe(450);
expect(summary.headline.bootIdleMiB).toBe(200);
expect(summary.headline.boardLoadedMiB).toBe(450);
expect(summary.headline.afterStressMiB).toBe(600);
@@ -153,6 +162,15 @@ describe("summarizeStress", () => {
expect(summary.checkpointCount).toBe(3);
});
it("compares on anon, not memory.current, so page cache cannot skew a run", () => {
const summary = summarizeStress([
parseStressSnapshot("01-boot-idle", 0, snapshot({ current: 500 * 1024 * 1024, anon: 100 * 1024 * 1024 })),
]);
expect(summary.headline.bootIdleAnonMiB).toBe(100);
expect(summary.headline.bootIdleMiB).toBe(500);
});
it("derives soak growth only from soak checkpoints", () => {
const summary = summarizeStress([
build("01-boot-idle", 1_000, 0),
@@ -160,7 +178,7 @@ describe("summarizeStress", () => {
build("soak-02", 200, 3_600_000),
]);
expect(summary.headline.soakGrowthMiBPerHour).toBe(100);
expect(summary.headline.soakAnonGrowthMiBPerHour).toBe(100);
});
it("leaves headline fields null when their checkpoints were not captured", () => {
@@ -168,7 +186,7 @@ describe("summarizeStress", () => {
expect(summary.headline.bootIdleMiB).toBeNull();
expect(summary.headline.boardLoadedMiB).toBeNull();
expect(summary.headline.soakGrowthMiBPerHour).toBeNull();
expect(summary.headline.soakAnonGrowthMiBPerHour).toBeNull();
});
it("reports the peak redis footprint across checkpoints", () => {