Skip to content

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

fix(bench): correct cgroup path resolution for containerised runs

Steven Enamakel0d77546dd4ee
diff --git a/bench/harnesses/bundles/Dockerfile b/bench/harnesses/bundles/Dockerfile
index 27d54c4b0e..11c70632a1 100644
--- a/bench/harnesses/bundles/Dockerfile
+++ b/bench/harnesses/bundles/Dockerfile
@@ -39,12 +39,15 @@ ARG OPENCLAW_VERSION
RUN npm install -g --prefix /opt/harness/openclaw --no-audit --no-fund openclaw@${OPENCLAW_VERSION}
COPY adapters/openclaw.sh /opt/harness/adapter.sh
-# Hermes ships its own installer, which stages Python and Node. Point HOME at
-# the bundle so everything it installs lands under /opt/harness; the adapter
-# copies that tree to a writable HOME at run time (counted in its cold start).
+# Hermes ships its own installer, which stages Python and Node and records
+# absolute paths. It must therefore be installed at the exact path it will run
+# from: install under /tmp/bench-home (the HOME every adapter uses), stash the
+# tree in the bundle, and have the adapter copy it back to /tmp/bench-home. The
+# copy is part of hermes's measured cold start.
FROM base AS hermes
ARG HERMES_VERSION
-ENV HOME=/opt/harness/home
+ENV HOME=/tmp/bench-home
RUN mkdir -p "$HOME" && curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash \
- && (/opt/harness/home/.local/bin/hermes --version || true)
+ && (/tmp/bench-home/.local/bin/hermes --version || true) \
+ && mv /tmp/bench-home /opt/harness/home
COPY adapters/hermes.sh /opt/harness/adapter.sh
diff --git a/bench/harnesses/bundles/adapters/hermes.sh b/bench/harnesses/bundles/adapters/hermes.sh
index a8a7fa4151..eb632c06e8 100755
--- a/bench/harnesses/bundles/adapters/hermes.sh
+++ b/bench/harnesses/bundles/adapters/hermes.sh
@@ -2,7 +2,7 @@
. "$(dirname "$0")/_common.sh"
# The installer put Python, Node and hermes under /opt/harness/home (read-only
# mount); give it a writable copy. This copy is part of hermes's measured cold start.
-cp -a /opt/harness/home/. "$HOME/"
+cp -a /opt/harness/home/. "$HOME/" # same absolute path the installer used
export PATH="$HOME/.local/bin:$PATH"
export HERMES_HOME="$HOME/.hermes"
mkdir -p "$HERMES_HOME"
diff --git a/bench/harnesses/report.mjs b/bench/harnesses/report.mjs
index 0599c0aa18..6ebe9ec50f 100644
--- a/bench/harnesses/report.mjs
+++ b/bench/harnesses/report.mjs
@@ -87,6 +87,10 @@ export function aggregate(meter, tasks) {
cold_start_ms_p50: percentile(coldStart, 50),
cpu_seconds_mean: mean(mine.map((t) => t.result?.resources?.cpu_seconds)),
avg_cpu_cores_mean: mean(mine.map((t) => t.result?.resources?.avg_cpu_cores)),
+ peak_anon_mb_max: (() => {
+ const v = mine.map((t) => t.result?.resources?.peak_anon_bytes).filter((x) => typeof x === "number");
+ return v.length ? Math.max(...v) / 1048576 : null;
+ })(),
peak_mem_mb_max: (() => {
const v = mine.map((t) => t.result?.resources?.peak_mem_bytes).filter((x) => typeof x === "number");
return v.length ? Math.max(...v) / 1048576 : null;
@@ -122,7 +126,8 @@ export function toMarkdown(meta, summary) {
["cold start to first call p50 (ms)", (s) => f(s.cold_start_ms_p50)],
["CPU-seconds / task", (s) => f(s.cpu_seconds_mean, 1)],
["avg CPU cores", (s) => f(s.avg_cpu_cores_mean, 2)],
- ["peak RAM max (MB)", (s) => f(s.peak_mem_mb_max)],
+ ["peak RAM, process memory (MB)", (s) => f(s.peak_anon_mb_max)],
+ ["peak RAM incl. page cache (MB)", (s) => f(s.peak_mem_mb_max)],
["avg RAM (MB)", (s) => f(s.avg_mem_mb_mean)],
["LLM calls (errors)", (s) => `${s.llm_calls} (${s.llm_call_errors})`],
["prompt / completion tokens", (s) => `${s.prompt_tokens} / ${s.completion_tokens}`],
@@ -137,7 +142,7 @@ export function toMarkdown(meta, summary) {
head,
body,
"",
- "Small samples: treat differences as indicative, not a ranking. CPU/RAM are cgroup-wide per container (memory includes page cache). Cache % = cached / prompt tokens across all calls.",
+ "Small samples: treat differences as indicative, not a ranking. CPU/RAM are cgroup-wide per container; process memory is the cgroup's anon bytes (2 Hz poll), the page-cache figure is the kernel high-water mark. Cache % = cached / prompt tokens across all calls.",
"",
].join("\n");
}
diff --git a/bench/harnesses/runner/cgroup.mjs b/bench/harnesses/runner/cgroup.mjs
index 776f2379cd..a6f351a1f1 100644
--- a/bench/harnesses/runner/cgroup.mjs
+++ b/bench/harnesses/runner/cgroup.mjs
@@ -17,6 +17,17 @@ function readNumber(file) {
}
}
+/** Anonymous (process-owned) memory: what a harness's own RSS adds up to, without page cache. */
+function readAnonBytes() {
+ try {
+ const text = fs.readFileSync(`${ROOT}/memory.stat`, "utf8");
+ const m = text.match(/^anon\s+(\d+)/m);
+ return m ? Number(m[1]) : null;
+ } catch {
+ return null;
+ }
+}
+
function readCpuUsec() {
try {
const text = fs.readFileSync(`${ROOT}/cpu.stat`, "utf8");
@@ -34,6 +45,7 @@ export function readSample(now = Date.now()) {
cpu_usec: readCpuUsec(),
mem_bytes: readNumber("memory.current"),
mem_peak_bytes: readNumber("memory.peak"),
+ anon_bytes: readAnonBytes(),
};
}
@@ -71,6 +83,7 @@ export function summarize(samples) {
...samples.map((s) => s.mem_peak_bytes).filter((v) => v !== null),
);
const polledPeak = mems.length ? Math.max(...mems) : 0;
+ const anons = samples.map((s) => s.anon_bytes).filter((v) => v != null);
const wallSeconds = (last.epoch_ms - first.epoch_ms) / 1000;
const cpuSeconds = (last.cpu_usec - first.cpu_usec) / 1e6;
return {
@@ -78,6 +91,9 @@ export function summarize(samples) {
// 1.0 == one fully busy vCPU for the whole window
avg_cpu_cores: wallSeconds > 0 ? cpuSeconds / wallSeconds : null,
peak_mem_bytes: Math.max(kernelPeak, polledPeak) || null,
+ // anon excludes page cache (file reads, copies), so it is the fairer "RAM the harness used"
+ peak_anon_bytes: anons.length ? Math.max(...anons) : null,
+ avg_anon_bytes: anons.length ? anons.reduce((a, b) => a + b, 0) / anons.length : null,
avg_mem_bytes: mems.length ? mems.reduce((a, b) => a + b, 0) / mems.length : null,
wall_seconds: wallSeconds,
samples: samples.length,
diff --git a/bench/harnesses/runner/cgroup.test.mjs b/bench/harnesses/runner/cgroup.test.mjs
index ded61460b3..88babb9b7a 100644
--- a/bench/harnesses/runner/cgroup.test.mjs
+++ b/bench/harnesses/runner/cgroup.test.mjs
@@ -4,14 +4,15 @@ import { summarize } from "./cgroup.mjs";
test("summarize charges CPU between first and last sample, prefers kernel peak", () => {
const out = summarize([
- { epoch_ms: 0, cpu_usec: 1_000_000, mem_bytes: 100, mem_peak_bytes: 100 },
- { epoch_ms: 1000, cpu_usec: 3_000_000, mem_bytes: 300, mem_peak_bytes: 900 },
+ { epoch_ms: 0, cpu_usec: 1_000_000, mem_bytes: 100, mem_peak_bytes: 100, anon_bytes: 50 },
+ { epoch_ms: 1000, cpu_usec: 3_000_000, mem_bytes: 300, mem_peak_bytes: 900, anon_bytes: 120 },
{ epoch_ms: 2000, cpu_usec: 5_000_000, mem_bytes: 200, mem_peak_bytes: 900 },
]);
assert.equal(out.cpu_seconds, 4);
assert.equal(out.avg_cpu_cores, 2);
assert.equal(out.peak_mem_bytes, 900);
assert.equal(out.avg_mem_bytes, 200);
+ assert.equal(out.peak_anon_bytes, 120);
});
test("summarize reports null rather than zero when cgroup files were unreadable", () => {