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

Main's full check has failed at 40-43m twice today (4:38, 9:04); make it pass… #16658

Merged opened this in answer to

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

Merged

mason/forge:mason/16655-main-s-full-check-has-failed-at-40-43m-t → main 0 commits fork

  • Merged. mason/16655-main-s-full-check-has-failed-at-40-43m-t was merged into main as 0717e11.

Review

Sign in to review this change.
5 files changed +58 −9
docs/OPERATING.md +1 −1

Diff not shown — a line 2,622 characters wide (limit 2,000). +1 −1

View file
src/checks/run_tier.ts +2 −2
@@ -220,11 +220,11 @@ export async function runTier(lane: LaneState, x: Execution): Promise<CheckOutco
220220 for (const line of limitWarnings(manifest.limits)) write(line);
221221 const cellCpus = resolveLimits("step", manifest.limits).cpus;
222222 const shardCpus = checkShardCpus(cellCpus);
223 write(shardsLine(shardsInForce(app.db, shardCpus)));
223 write(shardsLine(shardsInForce(app.db, shardCpus, x.tier === "verify")));
224224 const env = childEnv({
225225 // The shard count an admin set (`core/capacity.ts`), else the
226226 // default sized to what this check's cell holds, never the pod's.
227 ...capacityEnv(app.db, shardCpus),
227 ...capacityEnv(app.db, shardCpus, x.tier === "verify"),
228228 CI: "1",
229229 FORGE_URL: options.forgeUrl,
230230 FORGE_CHECK: run.id,
src/checks/tier_runner.ts +2 −2
@@ -65,7 +65,7 @@ export async function tryRunner(
6565 // The shard count an admin set reaches a runner's check as it does one run here (#14844); the
6666 // default is sized as one run here is (`checkShardCpus`), never from the runner machine's CPUs.
6767 const shardCpus = checkShardCpus(resolveLimits("step", manifest.limits).cpus);
68 write(shardsLine(shardsInForce(app.db, shardCpus)));
68 write(shardsLine(shardsInForce(app.db, shardCpus, x.tier === "verify")));
6969 const sent = await send(app, {
7070 runId: x.runId,
7171 repoId: repo.id,
@@ -82,7 +82,7 @@ export async function tryRunner(
8282 ],
8383 // Only the check's own variables cross, never the forge's; the runner adds its cell's.
8484 env: {
85 ...capacityEnv(app.db, shardCpus),
85 ...capacityEnv(app.db, shardCpus, x.tier === "verify"),
8686 CI: "1",
8787 FORGE_URL: options.forgeUrl,
8888 FORGE_CHECK: run.id,
src/core/capacity.ts +22 −4
@@ -736,8 +736,8 @@ export function edgeSigninOn(db: Database): boolean {
736736 * default is sized from `cpus` — a check passes what its cell holds, so a
737737 * small cell is never told the pod's count.
738738 */
739 export function capacityEnv(db: Database, cpus?: number): Record<string, string> {
740 return { FORGE_CHECK_SHARDS: String(shardsInForce(db, cpus).count) };
739 export function capacityEnv(db: Database, cpus?: number, whole = false): Record<string, string> {
740 return { FORGE_CHECK_SHARDS: String(shardsInForce(db, cpus, whole).count) };
741741 }
742742
743743 /** Where the shard count in force came from: an admin's setting, the environment, or sized. */
@@ -747,12 +747,30 @@ export type ShardsSource = "setting" | "environment" | "sized";
747747 * The shard count {@link capacityEnv} hands a check, and where it came from: an admin's value,
748748 * else `FORGE_CHECK_SHARDS` in the forge's environment, else sized from `cpus`.
749749 */
750 export function shardsInForce(db: Database, cpus?: number): { count: number; source: ShardsSource } {
750 export function shardsInForce(
751 db: Database,
752 cpus?: number,
753 whole = false,
754 ): { count: number; source: ShardsSource } {
751755 const stored = storedCapacity(db, "checks.shards");
752756 if (stored !== undefined) return { count: Number(stored), source: "setting" };
753757 const env = explicitDefault("checks.shards");
754758 if (env !== undefined) return { count: Number(env), source: "environment" };
755 return { count: shardsForCpus(cpus ?? cpuLimit()), source: "sized" };
759 const sized = cpus ?? cpuLimit();
760 return { count: whole ? wholeSuiteShards(sized) : shardsForCpus(sized), source: "sized" };
761 }
762
763 /** Most shards the whole suite takes by default: it runs alone, at the lowest priority (#16655). */
764 const WHOLE_SUITE_SHARDS_MAX = 8;
765
766 /**
767 * Shards by default for a run of every test file (the verify tier): `min(8, cpus)`, at least one.
768 * Four shards left 10,000 s of work taking 40+ minutes on a cell of 16 CPUs; the pull's check
769 * keeps {@link shardsForCpus}, since several of those run at once.
770 */
771 export function wholeSuiteShards(cpus: number): number {
772 const n = Math.floor(cpus);
773 return Number.isFinite(n) ? Math.max(1, Math.min(WHOLE_SUITE_SHARDS_MAX, n)) : 1;
756774 }
757775
758776 /**
test/capacity-cpus.test.ts +31
@@ -23,6 +23,7 @@ import {
2323 provideCpusForTest,
2424 setCapacity,
2525 shardsForCpus,
26 wholeSuiteShards,
2627 } from "../src/core/capacity.ts";
2728 import { changedOf } from "../src/actions/capacity.ts";
2829 import { createUser } from "../src/core/users.ts";
@@ -37,6 +38,36 @@ afterEach(() => {
3738 provideCpusForTest(4);
3839 });
3940
41 describe("a run of the whole suite takes more shards than a pull's check", () => {
42 test.each([
43 // cpus, shards
44 [12, 8], // a 16-CPU cell's workers: 16 × 3/4
45 [8, 8],
46 [4, 4],
47 [1, 1],
48 [80, 8],
49 ])("%d CPUs: %d shards", (cpus, shards) => {
50 expect(wholeSuiteShards(cpus)).toBe(shards);
51 });
52
53 test("the verify tier is told 8 where a pull's check is told 4, and an admin's value wins for both", async () => {
54 const dataDir = await mkdtemp(join(tmpdir(), "forge-capacity-whole-"));
55 const app = createApp({ dataDir, port: 0 });
56 try {
57 delete process.env.FORGE_CHECK_SHARDS;
58 expect(capacityEnv(app.db, 12)).toEqual({ FORGE_CHECK_SHARDS: "4" });
59 expect(capacityEnv(app.db, 12, true)).toEqual({ FORGE_CHECK_SHARDS: "8" });
60 expect(capacityEnv(app.db, 2, true)).toEqual({ FORGE_CHECK_SHARDS: "2" });
61 process.env.FORGE_CHECK_SHARDS = "3";
62 expect(capacityEnv(app.db, 12, true)).toEqual({ FORGE_CHECK_SHARDS: "3" });
63 } finally {
64 delete process.env.FORGE_CHECK_SHARDS;
65 app.close();
66 await rm(dataDir, { recursive: true, force: true });
67 }
68 });
69 });
70
4071 describe("the defaults follow the CPUs", () => {
4172 // By hand: shards = min(4, cpus); checks = floor(cpus / (shards * 3)), 1..16.
4273 test.each([

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs