Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(ci): adjust lane execution logic for ex63 profile

Steven Enamakelad04c766c9e6
diff --git a/scripts/__tests__/self-hosted-lanes.test.mjs b/scripts/__tests__/self-hosted-lanes.test.mjs
index c64122e014..c0d5779756 100644
--- a/scripts/__tests__/self-hosted-lanes.test.mjs
+++ b/scripts/__tests__/self-hosted-lanes.test.mjs
@@ -500,15 +500,10 @@ test("private auxiliary coverage suites keep their failure and the lane report s
fs.rmSync(dir, { recursive: true, force: true });
});
-test("private runner runs cargo lanes one at a time and overlaps them with the light lanes", async () => {
+test("private runner serializes independent lanes after failures even when parallelism is requested", async () => {
const out = fs.mkdtempSync(path.join(os.tmpdir(), "lanes-private-"));
fs.mkdirSync(path.join(out, "logs"));
const check = (name, run) => ({ name, run, when: true, needs: [] });
- const cargo = (name, targetDir) => ({
- name,
- targetDir: path.join(out, targetDir),
- checks: [check(`${name}-check`, "sleep 0.3")],
- });
const plan = {
profile: "ex63",
lanes: [
@@ -516,29 +511,21 @@ test("private runner runs cargo lanes one at a time and overlaps them with the l
name: "first",
checks: [
check("fails", "exit 1"),
- check("continues", "sleep 0.3"),
+ check("continues", "echo continued"),
],
},
- cargo("cov", "cov"),
{ name: "second", checks: [check("independent", "echo independent")] },
- cargo("lint", "build"),
],
};
const runner = new Runner(plan, { out, maxParallel: 8 });
+ assert.equal(runner.maxParallel, 1);
const lanes = await runner.run();
- const span = (name) => {
- const checks = lanes.find((l) => l.name === name).checks;
- return [Date.parse(checks[0].start), Date.parse(checks.at(-1).end)];
- };
- const overlaps = (a, b) => span(a)[0] < span(b)[1] && span(b)[0] < span(a)[1];
assert.equal(lanes[0].checks[0].status, "failure");
assert.equal(lanes[0].checks[1].status, "success");
- assert.equal(lanes[2].checks[0].status, "success");
- // Each chain stays serial in plan order, also after a failure.
- assert.ok(span("second")[0] >= span("first")[1]);
- assert.ok(span("lint")[0] >= span("cov")[1], "two cargo lanes ran at once");
- // The chains run side by side.
- assert.ok(overlaps("first", "cov"), "light lane waited for the cargo lane");
+ assert.equal(lanes[1].checks[0].status, "success");
+ assert.ok(
+ Date.parse(lanes[1].checks[0].start) >= Date.parse(lanes[0].checks[1].end),
+ );
assert.equal(
new Runner({ ...plan, profile: "hosted" }, { out, maxParallel: 8 })
.maxParallel,
diff --git a/scripts/ci/self-hosted/lanes-plan.mjs b/scripts/ci/self-hosted/lanes-plan.mjs
index 98b2173051..524f5e0612 100644
--- a/scripts/ci/self-hosted/lanes-plan.mjs
+++ b/scripts/ci/self-hosted/lanes-plan.mjs
@@ -90,8 +90,7 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
const nodeCache = ex63 ? "${CI_CACHE_DIR:-/cache}/node-tools" : null;
const core = areas.rustCore;
- // Private lanes with a target dir run one after another (the cargo chain)
- // and share compatible build products; the others overlap them.
+ // Private lanes run sequentially and share compatible build products.
// Instrumented objects stay separate from ordinary build/link checks.
const targetDir = (lane) =>
ex63 ? `target/ci-private-${lane === "cov" ? "coverage" : "build"}` : null;
diff --git a/scripts/ci/self-hosted/lanes.mjs b/scripts/ci/self-hosted/lanes.mjs
index 67948658b9..c92f6f4575 100644
--- a/scripts/ci/self-hosted/lanes.mjs
+++ b/scripts/ci/self-hosted/lanes.mjs
@@ -325,9 +325,14 @@ export class Runner {
constructor(plan, { out, maxParallel, maxHeavy = Infinity }) {
this.plan = plan;
this.out = out;
+ // ex63 runs lanes one at a time. Overlapping the frontend lanes with the
+ // cargo chain was measured in run 39434038570 on 4 vCPU / 24 GB: vitest
+ // took 2.6x as long and cache restores 5.6x, rust-cov peaked at 19.4 GB,
+ // and nothing finished sooner, since compiles and tests already use every
+ // core.
this.maxParallel =
plan.profile === "ex63"
- ? 2
+ ? 1
: maxParallel > 0
? maxParallel
: plan.lanes.length;
@@ -551,39 +556,20 @@ export class Runner {
}
}
- /**
- * Lanes in one chain run one at a time, in plan order. On ex63 every lane
- * with a target dir is in the cargo chain (two whole-core compiles at once
- * would not fit the VM, and they share build products) and the rest in the
- * light chain, so frontend and static work overlaps the Rust lanes.
- * Elsewhere each lane is its own chain.
- */
- chainOf(lane) {
- if (this.plan.profile !== "ex63") return lane.name;
- return lane.targetDir ? "cargo" : "light";
- }
-
async runQueue() {
const queue = [...this.plan.lanes];
- const running = new Map(); // promise -> chain
+ const running = new Set();
const finished = [];
await new Promise((resolveAll) => {
const pump = () => {
- const busy = () => new Set(running.values());
- let i = 0;
- while (running.size < this.maxParallel && i < queue.length) {
- const chain = this.chainOf(queue[i]);
- if (busy().has(chain)) {
- i++;
- continue;
- }
- const [lane] = queue.splice(i, 1);
+ while (running.size < this.maxParallel && queue.length > 0) {
+ const lane = queue.shift();
const p = this.runLane(lane).then((r) => {
running.delete(p);
finished.push(r);
pump();
});
- running.set(p, chain);
+ running.add(p);
}
if (running.size === 0 && queue.length === 0) resolveAll();
};