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

small-machine-off test runs past its 2s per-test budget under load #16839

Merged opened this in answer to

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

Merged

mason/forge:mason/16833-small-machine-off-test-runs-past-its-2s → main 0 commits fork

  • Merged. mason/16833-small-machine-off-test-runs-past-its-2s was merged into main as 8f7b949.

Review

Sign in to review this change.
4 files changed +12 −20
scripts/test-honesty-allow.json −1
@@ -178,7 +178,6 @@
178178 "test/first-five-minutes-journey.test.ts": {"wait":1},
179179 "test/first-ten-minutes.test.ts": {"wait":4},
180180 "test/first_look.test.ts": {"wait":2},
181 "test/fixtures/cache-under.ts": {"mock":1},
182181 "test/fixtures/shard-crash-once.test.ts": {"wait":1},
183182 "test/flake.test.ts": {"wait":8,"timeout":1},
184183 "test/flow-clog-door.test.ts": {"wait":2},
src/web/pages/kept_page.ts +7 −1
@@ -38,8 +38,14 @@ interface KeptPage {
3838 /** A minute: `tree_cache.ts`'s `TTL_MS`, named here so neither module imports the other. */
3939 const TTL_MS = 60_000;
4040
41 /**
42 * Bytes the kept pages may hold on a machine of `machineBytes`: 64 MiB, a quarter of it under 1
43 * GiB.
44 */
45 export const keptPageBytes = (machineBytes?: number): number => cacheBytes(64 * 1024 * 1024, machineBytes);
46
4147 /** Bytes the kept pages may hold, shown on /system. */
42 export const KEPT_PAGE_BYTES = cacheBytes(64 * 1024 * 1024);
48 export const KEPT_PAGE_BYTES = keptPageBytes();
4349 const store = new ViewCache({ maxEntries: 8192, maxBytes: KEPT_PAGE_BYTES });
4450
4551 /**
test/fixtures/cache-under.ts deleted −9
@@ -1,9 +0,0 @@
1 // Run by test/small-machine-off.test.ts: the page caches made on a machine of argv[2] bytes.
2 import { mock } from "bun:test";
3 import { join } from "node:path";
4
5 const src = join(import.meta.dir, "..", "..", "src");
6 mock.module(join(src, "system", "memory_limit.ts"), () => ({ memoryLimitBytes: () => Number(process.argv[2]) }));
7 const { KEPT_PAGE_BYTES } = await import(join(src, "web", "pages", "kept_page.ts"));
8 const { largePageCache } = await import(join(src, "system", "cache_share.ts"));
9 console.log(JSON.stringify({ KEPT_PAGE_BYTES, largePageCache }));
test/small-machine-off.test.ts +5 −9
@@ -9,6 +9,7 @@ import { serve, type Servers } from "../src/http/server.ts";
99 import { createRepo } from "../src/actions/repos.ts";
1010 import { createToken } from "../src/core/tokens.ts";
1111 import { cacheBytes, cacheShare, LARGE_CACHE_MIN_BYTES } from "../src/system/cache_share.ts";
12 import { KEPT_PAGE_BYTES, keptPageBytes } from "../src/web/pages/kept_page.ts";
1213 import { findChromium } from "../src/looks/capture.ts";
1314 import { optionals } from "../src/system/footprint.ts";
1415 import { readHealth } from "../src/actions/health.ts";
@@ -26,15 +27,10 @@ test("under 1 GiB the page caches keep a quarter; from 1 GiB, all of it", () =>
2627 expect(cacheBytes(64 * MIB, 4096 * MIB)).toBe(64 * MIB);
2728 });
2829
29 test("the kept-page cache is made a quarter of its size under 1 GiB, and whole from 1 GiB", async () => {
30 const made = async (bytes: number) => {
31 const p = Bun.spawn(["bun", join(import.meta.dir, "fixtures", "cache-under.ts"), String(bytes)], { stdout: "pipe", stderr: "pipe" });
32 const [out, code] = await Promise.all([new Response(p.stdout).text(), p.exited]);
33 expect(code).toBe(0);
34 return JSON.parse(out) as { KEPT_PAGE_BYTES: number; largePageCache: boolean };
35 };
36 expect(await made(512 * MIB)).toEqual({ KEPT_PAGE_BYTES: 16 * MIB, largePageCache: false });
37 expect(await made(4096 * MIB)).toEqual({ KEPT_PAGE_BYTES: 64 * MIB, largePageCache: true });
30 test("the kept-page cache is made a quarter of its size under 1 GiB, and whole from 1 GiB", () => {
31 expect(keptPageBytes(512 * MIB)).toBe(16 * MIB);
32 expect(keptPageBytes(4096 * MIB)).toBe(64 * MIB);
33 expect(KEPT_PAGE_BYTES).toBe(keptPageBytes());
3834 });
3935
4036 test("each optional part is listed on or off with its one-line reason", () => {

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs