Files
zeekayandHanzo Dev 0a69c0f7f5 The load is part of the host
MEASURED.md said memory is deterministic and has no range. On a host at load
average 3 it is: 573.0 MB and 601 bytes per agent, twelve for twelve,
byte-identical across three separately built binaries. On a second host at load
17 to 73 the same lane read 594, 595, 596 and 599.

Two things differ between those and this pass cannot separate them — the
machines are not the same machine, and only one was busy. The cross-machine part
is already known, an M1 Max and an M4 Max differ by about five bytes here. So
the line now says what was observed and not a cause: determinism under quiet
conditions, about 1% of variation under load, unresolved.

AND THE LANES NOW SAY WHICH THEY WERE. host.sh, say.mjs and goroutine/main.go
all print the one-minute load beside the CPU and core count, because a reader
cannot tell a busy machine from a quiet one after the fact and this is exactly
the distinction the paragraph above turns on.

While wiring it: MEASURED.md claimed "every lane that measures time prints its
host", and fleet, sandbox and pricing printed none at all — platform.mjs
harvests lane output by looking for that very line, so it recorded no host for
any of the three. say.mjs has the function now and all three call it, so the
sentence is true of both halves.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-16 10:04:47 -07:00

55 lines
2.1 KiB
JavaScript

/**
* One row of a lane's table, and — when `BENCH_JSON` names a file — one entry in
* it. The shell lanes have this in `host.sh`; these are the same two lines for
* the ones written in node, so a row reaches the terminal and the file by the
* same call and the two cannot disagree.
*
* The value is a string. A lane says "455 MB (477 bytes per agent)" as readily
* as it says a number, and a reader that wants a number knows which row it
* asked for.
*/
import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs'
import { execFileSync } from 'node:child_process'
import { cpus, arch, loadavg } from 'node:os'
const FILE = process.env.BENCH_JSON || ''
export function say(label, value) {
console.log(`${String(label).padEnd(26)} ${value}`)
if (!FILE) return
let rows = []
if (existsSync(FILE)) {
try {
rows = JSON.parse(readFileSync(FILE, 'utf8'))
} catch {
rows = []
}
}
rows.push({ label: String(label), value: String(value) })
writeFileSync(FILE, JSON.stringify(rows, null, 1))
}
/**
* The machine a number came from, for the lanes written in node.
*
* host.sh has had this for the shell lanes and MEASURED.md said "every lane that
* measures time prints its host" — but fleet, sandbox and pricing printed none,
* and platform.mjs harvests lane output by looking for exactly this line, so it
* recorded no host for any of them. One sentence, true of both halves now.
*
* The load average is part of it: the same lane on one laptop read 601 bytes per
* agent at load 3 and 594 at load 73, and a reader cannot tell after the fact.
*/
export function host() {
let cpu = 'unknown', os = process.platform
try {
if (process.platform === 'darwin') {
cpu = execFileSync('sysctl', ['-n', 'machdep.cpu.brand_string'], { encoding: 'utf8' }).trim()
os = `macOS ${execFileSync('sw_vers', ['-productVersion'], { encoding: 'utf8' }).trim()}`
} else {
cpu = cpus()[0]?.model?.trim() || 'unknown'
}
} catch {}
console.log(`host: ${cpu} · ${cpus().length} cores · ${arch()} · ${os} · load ${loadavg()[0].toFixed(2)}\n`)
}