Metabolism: region pool — SharedArrayBuffer arena, band-parallel phases (block sums / VM decisions / advection+reaction), bit-identical to serial; 5.9x at 41k organisms; provider protocol sketched

This commit is contained in:
Dejvino
2026-10-28 15:25:52 +01:00
parent 3a72525ccb
commit d6e97a2b52
5 changed files with 685 additions and 268 deletions
+10 -3
View File
@@ -23,8 +23,14 @@ function plant(w) {
w.recount();
}
for (const vmEvery of [1, 2, 3]) {
const w = new World(song, { fps: 30, field: 128, genesis: 0, vmEvery });
const configs = [];
for (const a of process.argv.slice(4)) {
if (a.startsWith('w')) configs.push({ workers: Number(a.slice(1)) });
else if (a.startsWith('v')) configs.push({ vmEvery: Number(a.slice(1)) });
}
if (!configs.length) configs = [{ workers: 0, vmEvery: 2 }, { workers: 2 }, { workers: 4 }];
for (const cfg of configs) {
const w = new World(song, { fps: 30, field: 128, genesis: 0, vmEvery: cfg.vmEvery ?? 2, workers: cfg.workers ?? 0 });
plant(w);
const start = w.count;
// warm-up
@@ -32,5 +38,6 @@ for (const vmEvery of [1, 2, 3]) {
const t0 = process.hrtime.bigint();
for (let f = 0; f < frames; f++) w.step();
const ms = Number(process.hrtime.bigint() - t0) / 1e6 / frames;
console.log(`vmEvery=${vmEvery} sim ${ms.toFixed(1)} ms/frame (start ${Math.round(start)}, now ${Math.round(w.count)}, peak-ish budget ${Math.round(w.cap).toLocaleString()})`);
console.log(`workers=${w.pool?.length ?? 0} vmEvery=${w.vmEvery} sim ${ms.toFixed(1)} ms/frame (start ${Math.round(start)}, now ${Math.round(w.count)})`);
w.dispose?.();
}