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

The home's lanes and figures never wait on a 44 s statement, and three things… #16513

Merged opened this in answer to

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

Merged

scout/forge:scout/16189-the-home-s-lanes-and-figures-never-wait → main 0 commits fork 1 thread · 1 unresolved

  • Merged. scout/16189-the-home-s-lanes-and-figures-never-wait was merged into main as 3f0e50c.

Review

Sign in to review this change.
7 files changed +28 −51
docs/features/runners.md +4 −5
@@ -34,11 +34,10 @@ started by hand are in addition: an admin removes them with
3434 `DELETE /api/v1/admin/runners/<id>`. Every `local-*` row created by `forge` is
3535 deleted at each boot, so never name a hand-made runner `local-N`.
3636
37 `checks.concurrency` counts the forge's own cells; under the runner placement
38 each runner seen in the last minute adds the jobs it runs at once
39 (`FORGE_RUNNER_JOBS`, which every claim tells the forge), up to the setting's
40 ceiling of 16. One that stops asking stops counting a minute later, with no
41 restart (#15253).
37 `checks.concurrency` is the most checks running at once, whoever runs them: the forge's own
38 cells or any number of runners. Runners only decide where a check runs, never how many
39 (#16189). What a runner says it runs at once (`FORGE_RUNNER_JOBS`, told in every claim) is
40 shown beside it in Settings → Runners and the terminal, and limits nothing.
4241
4342 Settings → Runners (`/settings/runners`) and the terminal's **Runners** list the same rows, with
4443 a remove for a hand-made one: [settings-runners.md](settings-runners.md).
src/checks/lane_state.ts +5 −9
@@ -8,7 +8,6 @@ import { Gate } from "../git/env.ts";
88 import { runStep } from "../apps/process.ts";
99 import type { DeepsecDeps } from "./deepsec_step.ts";
1010 import { CAPACITY, capacityCount } from "../core/capacity.ts";
11 import { liveRunnerJobs } from "./runner_jobs.ts";
1211 import type { Placement } from "./placement.ts";
1312 import type { PodRoom } from "./pod_room.ts";
1413 import type { GateStage } from "./gate_reason.ts";
@@ -224,13 +223,10 @@ export const CHECKS_CEILING = ((kind) => (kind.type === "count" ? kind.max : 16)
224223
225224 /**
226225 * How many checks may run at once, read on every pick (`core/capacity.ts`): an admin's change is
227 * honoured by the next check, not the next boot. `concurrency` is the boot default. Under the
228 * runner placement the jobs of every live runner add to it (`liveRunnerJobs`), so one that
229 * connects raises it at the next tick and one gone quiet drops out once `SEEN_FRESH_MS` passes;
230 * never above `CHECKS_CEILING`, so a crowd of runners cannot overload this machine's lane.
226 * honoured by the next check, not the next boot. `concurrency` is the boot default. The setting is
227 * the most checks at once, whoever runs them: live runners only decide where a check runs, never
228 * how many (#16189; adding their jobs ran 16 at once where the setting said 6).
231229 */
232 export function capacity(lane: LaneState, now: number = Date.now()): number {
233 const setting = capacityCount(lane.app.db, "checks.concurrency", lane.options.concurrency ?? 1);
234 const runners = lane.placement.mode === "runner" ? liveRunnerJobs(lane.app.db, now) : 0;
235 return Math.min(CHECKS_CEILING, setting + runners);
230 export function capacity(lane: LaneState): number {
231 return Math.min(CHECKS_CEILING, capacityCount(lane.app.db, "checks.concurrency", lane.options.concurrency ?? 1));
236232 }
src/checks/runner_jobs.ts −12
@@ -222,18 +222,6 @@ export function noteRunnerJobs(db: Database, runnerId: string, said: unknown): v
222222 db.query("UPDATE check_runner SET jobs = ?2 WHERE id = ?1 AND jobs != ?2").run(runnerId, said);
223223 }
224224
225 /**
226 * The jobs the live runners run at once: the sum of each one's count over those seen within
227 * `SEEN_FRESH_MS`. One not seen since stops counting on the next read, with no restart.
228 */
229 export function liveRunnerJobs(db: Database, now: number): number {
230 return (
231 db
232 .query<{ n: number | null }, [number]>("SELECT SUM(jobs) AS n FROM check_runner WHERE seen_at > ?1")
233 .get(now - SEEN_FRESH_MS)?.n ?? 0
234 );
235 }
236
237225 /**
238226 * Put a check's steps on the desk. `dir` is the bare repository the commit is in; it stays here.
239227 */
src/core/capacity.ts +1 −1
@@ -74,7 +74,7 @@ export const CAPACITY: Record<CapacityKey, Definition> = {
7474 fallback: "1",
7575 sized: (cpus) => checksForCpus(cpus - servingCoresForCpus(cpus), shardsForCpus(cpus)),
7676 reason: "A check runs a whole test suite; more at once starve the web process of CPU.",
77 help: "How many repository checks run at once on this forge's own cells; each runner seen in the last minute adds the jobs it runs at once, up to 16 in all. Lowering it lets running ones finish; the next one waits. Empty: the pod's CPUs less the ones kept for the forge itself (cells.servingCores' default), over three per shard (shards × 3), from 1 to 16 — 80 CPUs keep 4 and give 76 / 12 = 6.",
77 help: "The most repository checks running at once, whoever runs them: runners decide where a check runs, never how many. Lowering it lets running ones finish; the next one waits. Empty: the pod's CPUs less the ones kept for the forge itself (cells.servingCores' default), over three per shard (shards × 3), from 1 to 16 — 80 CPUs keep 4 and give 76 / 12 = 6.",

The new help text is right, but docs/features/runners.md still describes the old additive behaviour. Update it in this pull.

7878 },
7979 "checks.shards": {
8080 label: "Test shards per check",
src/flow/ship_time.ts +1 −1
@@ -136,7 +136,7 @@ function shipped(db: Database, since: string, to: string): { issue: Closed; ship
136136 const issues = db
137137 .query<Closed, [string, string]>(
138138 `SELECT i.id, i.repo_id, i.number, i.title, i.closed_at, o.username AS owner, r.name,
139 (SELECT MIN(x.started_at) FROM run x
139 (SELECT MIN(x.started_at) FROM run x INDEXED BY run_agent_issue_latest
140140 WHERE x.issue_id = i.id AND x.kind = 'agent' AND x.started_at IS NOT NULL) AS first_start
141141 FROM issue i INDEXED BY issue_closed_done
142142 JOIN repo r ON r.id = i.repo_id JOIN user o ON o.id = r.owner_id
test/checks-runner-capacity.test.ts +9 −23
@@ -11,7 +11,7 @@ import { join } from "node:path";
1111 import { createApp, type App } from "../src/app.ts";
1212 import { CHECKS_CEILING, capacity, type LaneState } from "../src/checks/lane_state.ts";
1313 import type { Placement } from "../src/checks/placement.ts";
14 import { enrolRunner, liveRunnerJobs, noteRunnerJobs, runnerByToken, SEEN_FRESH_MS } from "../src/checks/runner_jobs.ts";
14 import { enrolRunner, noteRunnerJobs, runnerByToken } from "../src/checks/runner_jobs.ts";
1515 import { CAPACITY, setCapacity } from "../src/core/capacity.ts";
1616
1717 let dataDir: string;
@@ -31,38 +31,26 @@ const lane = (placement: Placement, concurrency = 2): LaneState =>
3131
3232 const T = 10_000_000;
3333
34 test("the setting plus the jobs of live runners, under the runner placement only", () => {
34 test("the setting is the most checks at once, however many runners are live (#16189)", () => {
3535 const runner = lane({ mode: "runner", waitMs: 300 });
36 expect(capacity(runner, T)).toBe(2);
36 expect(capacity(runner)).toBe(2);
3737 const one = enrolRunner(app.db, "one", "admin");
3838 const two = enrolRunner(app.db, "two", "admin");
3939 runnerByToken(app.db, one.token, T);
40 expect(capacity(runner, T)).toBe(3);
4140 runnerByToken(app.db, two.token, T);
4241 noteRunnerJobs(app.db, two.runner.id, 4);
43 expect(liveRunnerJobs(app.db, T)).toBe(5);
44 expect(capacity(runner, T)).toBe(7);
45 // An admin's setting is read on every pick, and the runners add to it.
42 expect(capacity(runner)).toBe(2);
43 // An admin's setting is read on every pick; runners still add nothing.
4644 setCapacity(app.db, "checks.concurrency", "3", "admin");
47 expect(capacity(runner, T)).toBe(8);
45 expect(capacity(runner)).toBe(3);
4846 setCapacity(app.db, "checks.concurrency", null, "admin");
49 // Runners never take a check under the process placement: they add nothing there.
50 expect(capacity(lane({ mode: "process" }), T)).toBe(2);
51 });
52
53 test("a runner not seen within SEEN_FRESH_MS stops counting, with no restart", () => {
54 const runner = lane({ mode: "runner", waitMs: 300 });
55 expect(capacity(runner, T + SEEN_FRESH_MS - 1)).toBe(7);
56 expect(capacity(runner, T + SEEN_FRESH_MS)).toBe(2);
47 expect(capacity(lane({ mode: "process" }))).toBe(2);
5748 });
5849
5950 test("never above the setting's own ceiling", () => {
60 const big = enrolRunner(app.db, "big", "admin");
61 runnerByToken(app.db, big.token, T);
62 noteRunnerJobs(app.db, big.runner.id, 64);
6351 const kind = CAPACITY["checks.concurrency"].kind;
6452 expect(CHECKS_CEILING).toBe(kind.type === "count" ? kind.max : -1);
65 expect(capacity(lane({ mode: "runner", waitMs: 300 }), T)).toBe(CHECKS_CEILING);
53 expect(capacity(lane({ mode: "runner", waitMs: 300 }, 999))).toBe(CHECKS_CEILING);
6654 });
6755
6856 test("a count a claim says is kept only when it is a whole number from 1 to 64", () => {
@@ -77,7 +65,5 @@ test("a count a claim says is kept only when it is a whole number from 1 to 64",
7765 });
7866
7967 test("the setting's line says what it counts", () => {
80 expect(CAPACITY["checks.concurrency"].help).toStartWith(
81 "How many repository checks run at once on this forge's own cells; each runner seen in the last minute adds the jobs it runs at once, up to 16 in all.",
82 );
68 expect(CAPACITY["checks.concurrency"].help).toStartWith("The most repository checks running at once, whoever runs them");
8369 });
test/hot-reads-indexed.test.ts +8
@@ -100,3 +100,11 @@ test("a page-view flush counts a visitor's day from the visitor index, not the s
100100 expect(lines.join("\n")).toContain("traffic_view_scope_visitor_at");
101101 noScan(lines.filter((l) => l !== "SCAN CONSTANT ROW"));
102102 });
103
104 test("the home's ship time reads each issue's first agent run by index, with no statistics (#16189)", async () => {
105 expect(app.db.query("SELECT 1 FROM sqlite_master WHERE name = 'sqlite_stat1'").get()).toBeNull();
106 const { readShipTime } = await import("../src/flow/ship_time.ts");
107 const lines = plans(() => void readShipTime(app.db, new Date()));
108 expect(lines.join("\n")).toContain("run_agent_issue_latest");
109 expect(lines.join("\n")).not.toContain("run_kind_started");
110 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs