test(bench): alternate the whole router order per lookup run
Only the import order alternated between processes; warm-up order and the shared lookup call site always saw the first-listed router first. CARD-10's A/A run (oracle vs a byte-identical copy) showed a steady bias of up to +8.3% against the second-listed router at 10 routes. Reversing the whole order per process brings the same A/A to -0.1% (8 x 21 rounds on jarvis). Owner-approved D4 method change (2026-10-12). Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
1 file changed
+11
-9
+11
-9
@@ -15,14 +15,14 @@
|
|||||||
* Each router is a module exporting `resolveRoute` and `allowedMethods` with the `src/http/router.ts`
|
* Each router is a module exporting `resolveRoute` and `allowedMethods` with the `src/http/router.ts`
|
||||||
* signatures. All routers are loaded into the same process and **interleaved**: per cell, every
|
* signatures. All routers are loaded into the same process and **interleaved**: per cell, every
|
||||||
* router is warmed, then each round takes one sample from each router, alternating which goes first
|
* router is warmed, then each round takes one sample from each router, alternating which goes first
|
||||||
* (AB, BA, AB, ...). Every router after the first is reported against the first as the median of the
|
* (AB, BA, AB, ...). Fresh processes alternate the whole router order, warm-up included. Every router after the first is reported against the first as the median of the
|
||||||
* per-round B/A ratios, with a bootstrap 95% CI. Interleaving puts drift and background load on both
|
* per-round B/A ratios, with a bootstrap 95% CI. Interleaving puts drift and background load on both
|
||||||
* sides of each ratio instead of on whichever ran later. With one router it reports absolute numbers
|
* sides of each ratio instead of on whichever ran later. With one router it reports absolute numbers
|
||||||
* only. Do not edit the generator, the workloads or the defaults between a baseline and its
|
* only. Do not edit the generator, the workloads or the defaults between a baseline and its
|
||||||
* comparison: they are the method.
|
* comparison: they are the method.
|
||||||
*
|
*
|
||||||
* Env: `LOOKUP_ROUTERS` (label=path list, default `live=src/http/router.ts`), `LOOKUP_RUNS` (4 fresh
|
* Env: `LOOKUP_ROUTERS` (label=path list, default `live=src/http/router.ts`), `LOOKUP_RUNS` (4 fresh
|
||||||
* processes, import order alternating), `LOOKUP_ROUNDS` (21 per cell per run, minimum 15), `LOOKUP_SAMPLE_MS` (25),
|
* processes, router order alternating), `LOOKUP_ROUNDS` (21 per cell per run, minimum 15), `LOOKUP_SAMPLE_MS` (25),
|
||||||
* `LOOKUP_WARMUP_MS` (250 per router per cell), `LOOKUP_OUT` (bench/lookup-results.json). Any other
|
* `LOOKUP_WARMUP_MS` (250 per router per cell), `LOOKUP_OUT` (bench/lookup-results.json). Any other
|
||||||
* `LOOKUP_*` variable (e.g. `LOOKUP_HOST`, `LOOKUP_CPUSET`) is copied into the record as a note.
|
* `LOOKUP_*` variable (e.g. `LOOKUP_HOST`, `LOOKUP_CPUSET`) is copied into the record as a note.
|
||||||
*/
|
*/
|
||||||
@@ -159,13 +159,15 @@ function measureCell(loaded: Loaded, routes: Route[], w: Workload): Cell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function child(routers: Array<[string, string]>): Promise<void> {
|
async function child(routers: Array<[string, string]>): Promise<void> {
|
||||||
// Import order alternates per run (LOOKUP_IMPORT_REVERSED): which copy V8 sees first can bias an
|
// Router order alternates per run (LOOKUP_IMPORT_REVERSED): import order, warm-up order and which
|
||||||
// in-process comparison of otherwise identical code, and alternating spreads that over both sides.
|
// router opens each cell's first round. Whichever router V8 sees first, in import or in the shared
|
||||||
const imports = process.env.LOOKUP_IMPORT_REVERSED === '1' ? [...routers].reverse() : routers;
|
// `lookup` call site, can bias an in-process comparison of otherwise identical code; alternating
|
||||||
const modules = new Map<string, RouterModule>();
|
// all of it spreads that over both sides. Reversing only the import order left an A/A bias of up
|
||||||
for (const [label, path] of imports)
|
// to +8% on the second-listed router (CARD-10).
|
||||||
modules.set(label, (await import(pathToFileURL(resolve(path)).href)) as RouterModule);
|
const ordered = process.env.LOOKUP_IMPORT_REVERSED === '1' ? [...routers].reverse() : routers;
|
||||||
const loaded: Loaded = routers.map(([label]) => ({ label, router: modules.get(label)! }));
|
const loaded: Loaded = [];
|
||||||
|
for (const [label, path] of ordered)
|
||||||
|
loaded.push({ label, router: (await import(pathToFileURL(resolve(path)).href)) as RouterModule });
|
||||||
|
|
||||||
const cells: Cell[] = [];
|
const cells: Cell[] = [];
|
||||||
for (const count of ROUTE_COUNTS) {
|
for (const count of ROUTE_COUNTS) {
|
||||||
|
|||||||
Reference in new issue
Block a user