Public: anyone can read this; the crew can change it.
small-machine-off test runs past its 2s per-test budget under load #16839
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/16833-small-machine-off-test-runs-past-its-2s → main 0 commits fork
4 files
changed +12
−20
scripts/test-honesty-allow.json −1
| @@ -178,7 +178,6 @@ | ||
| 178 | 178 | "test/first-five-minutes-journey.test.ts": {"wait":1}, |
| 179 | 179 | "test/first-ten-minutes.test.ts": {"wait":4}, |
| 180 | 180 | "test/first_look.test.ts": {"wait":2}, |
| 181 | "test/fixtures/cache-under.ts": {"mock":1}, | |
| 182 | 181 | "test/fixtures/shard-crash-once.test.ts": {"wait":1}, |
| 183 | 182 | "test/flake.test.ts": {"wait":8,"timeout":1}, |
| 184 | 183 | "test/flow-clog-door.test.ts": {"wait":2}, |
src/web/pages/kept_page.ts +7 −1
| @@ -38,8 +38,14 @@ interface KeptPage { | ||
| 38 | 38 | /** A minute: `tree_cache.ts`'s `TTL_MS`, named here so neither module imports the other. */ |
| 39 | 39 | const TTL_MS = 60_000; |
| 40 | 40 | |
| 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 | ||
| 41 | 47 | /** 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(); | |
| 43 | 49 | const store = new ViewCache({ maxEntries: 8192, maxBytes: KEPT_PAGE_BYTES }); |
| 44 | 50 | |
| 45 | 51 | /** |
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"; | ||
| 9 | 9 | import { createRepo } from "../src/actions/repos.ts"; |
| 10 | 10 | import { createToken } from "../src/core/tokens.ts"; |
| 11 | 11 | 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"; | |
| 12 | 13 | import { findChromium } from "../src/looks/capture.ts"; |
| 13 | 14 | import { optionals } from "../src/system/footprint.ts"; |
| 14 | 15 | 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", () => | ||
| 26 | 27 | expect(cacheBytes(64 * MIB, 4096 * MIB)).toBe(64 * MIB); |
| 27 | 28 | }); |
| 28 | 29 | |
| 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()); | |
| 38 | 34 | }); |
| 39 | 35 | |
| 40 | 36 | test("each optional part is listed on or off with its one-line reason", () => { |
new above
offline