perf(bench): record the pre-radix lookup baseline at ed47836
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 15s
CI / build (pull_request) Successful in 25s
CI / runtimes (edge) (pull_request) Successful in 14s
CI / runtimes (deno) (pull_request) Successful in 21s

The baseline CARD-10 compares the radix index against, captured before any
router change. Kept with its environment record and every raw sample.

bench:lookup on the linear matcher, five runs of 105 samples per cell. Median
ns per lookup:

  routes  static hit  late param  method miss  path miss
  10            61.3       123.3        313.1      247.1
  100           67.6       343.4       1263.7     1463.3
  500           67.8      1326.8       6732.2     8973.4

Run-to-run spread of the per-run medians is 2.0-17.5%. An A/A run (live
router against the byte-identical oracle, same protocol) differs by +5.2% on
the 10-route static hit and by at most 2.7% elsewhere, so D4's 5% limit at 10
routes sits at the noise floor for that cell. That is recorded for the D4
decision, not resolved here.

bench:compare, run once A/A, is stored separately as end-to-end req/s only:
every case within 1.9%.

Measured on an Apple M4 Max on battery power, load average 2.4-3.4 on 16
cores; the comparison run should use the same power source.

Refs #109

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-10-10 17:27:26 -05:00
1 parent a47c6564ab
commit a4562b2b23
9 files changed
+6294

No files matched your search

+90
View File
@@ -0,0 +1,90 @@
# Pre-radix router baseline — `ed47836`
The performance half of the CARD-08 parity corpus (FPRD-001, #109). Captured before any CARD-07
router change; immutable through CARD-07 review, like `test/router-parity/`. CARD-10 measures the
radix index with the **same harness, same defaults, same machine class**, and compares against
these files. Do not re-run into this directory: a new capture goes in a new directory.
## Files
| File | What it is |
|---|---|
| `lookup-raw.json` | **The D4 baseline.** `bench:lookup` on the live linear matcher: environment, method, every sample of every run, and the summary. |
| `lookup-summary.txt` | The table `bench:lookup` printed for that run. |
| `lookup-aa-raw.json`, `lookup-aa-summary.txt` | A/A noise check: the live router against the byte-identical frozen oracle (`test/router-parity/oracle.ts`), same alternating protocol. Any difference here is noise. |
| `compare-e2e-raw.json`, `compare-e2e-summary.txt`, `compare-e2e-stderr.txt` | `npm run bench:compare`, run once with this tree as both base and head. **End-to-end req/s signal only**: 50/200 *filler* routes plus base routes, not 10/100/500 total, and not lookup time. It cannot decide D4. |
| `load.txt` | `uptime` before and after each run. |
## Environment
| | |
|---|---|
| Hardware | Apple M4 Max (`Mac16,5`), 16 cores (12 performance + 4 efficiency), 64 GiB |
| Power | **On battery** (84%, discharging) for every run. macOS may manage clocks differently on AC; run the CARD-10 comparison on the same power source, or re-capture both on AC. |
| OS | macOS 27.0.1 (build 26A434), Darwin 27.0.0 arm64 |
| Node | v22.22.2 (V8 12.4.254.21-node.39) |
| Packages | `@green-tea/core@26.9.0-beta.2`; tsx 4.23.5, typescript 5.9.3, vitest 4.1.11, autocannon 8.0.0 (from `package-lock.json`) |
| Core revision | Router source at `ed47836c9820c47bf4ed5e902d91e019abdb110a`. The harness ran from `98ea948` (this branch), whose `src/` is byte-identical to `ed47836` — the branch adds only tests and bench files. |
| Env vars | `LOOKUP_OUT` only (and `LOOKUP_ROUTERS` for the A/A run); no `NODE_OPTIONS`. Recorded in each raw file under `meta.env`. |
| Load | 1-minute load average 2.4–3.4 on 16 cores throughout (see `load.txt` and `meta.loadavgAtStart/End`). Foreground apps were a browser and the window server; nothing else CPU-bound. |
## Method (`bench/lookup.ts`, defaults)
- **Operation:** `resolveRoute(routes, method, path)`, and on `undefined`, `allowedMethods(routes, path)` — what `dispatch` does after `normalizeRequestPath`. Normalization is excluded.
- **Route counts:** 10, 100 and 500 **total registered HTTP routes**.
- **Generator:** N−2 fillers cycling `GET /res{k}/items`, `POST /res{k}/items`, `GET /res{k}/items/:id`, `PUT /res{k}/items/:id(\d+)`, `GET /res{k}/files/:path*` (k = ⌊i/5⌋), then `GET /static/target/leaf`, then `GET /late/:group/:id` declared last.
- **Workloads:** static hit `GET /static/target/leaf`; late parameter hit `GET /late/g1/42`; method miss `DELETE /static/target/leaf` (Allow `GET, HEAD, OPTIONS`); path miss `GET /nowhere/at/all`. Each answer is asserted before timing.
- **Order:** for each run, for each router (order alternates per run), for count 10 → 100 → 500, for the four workloads in the order above.
- **Warm-up:** 250 ms per cell, time-boxed; it also calibrates iterations so one sample lasts ≈25 ms (iteration counts are stored per cell).
- **Repetitions:** 5 runs, each a fresh child process; 21 samples per cell per run → 105 samples per cell. Every sample is kept.
- **Statistic:** median ns per lookup over all 105 samples. Run spread = (max − min of the five per-run medians) / median.
## Baseline (median ns per lookup, `lookup-raw.json`)
| Routes | Static hit | Late param hit | Method miss | Path miss |
|---:|---:|---:|---:|---:|
| 10 | 61.3 (spread 17.5%) | 123.3 (6.2%) | 313.1 (4.6%) | 247.1 (6.8%) |
| 100 | 67.6 (8.0%) | 343.4 (2.1%) | 1 263.7 (3.5%) | 1 463.3 (3.2%) |
| 500 | 67.8 (7.5%) | 1 326.8 (16.5%) | 6 732.2 (6.5%) | 8 973.4 (2.0%) |
## Noise floor (A/A, `lookup-aa-raw.json`)
Identical matcher code under two labels, alternating order per run. Median difference
(oracle − live) / live:
| Routes | Static hit | Late param hit | Method miss | Path miss |
|---:|---:|---:|---:|---:|
| 10 | +5.2% | 0.0% | +1.2% | +0.2% |
| 100 | −0.1% | −0.8% | −0.1% | +0.1% |
| 500 | −2.7% | +0.3% | −0.4% | +0.1% |
**For D4:** with no code difference at all, the 10-route static hit already moves 5.2% — the
size of the proposed ≤5% regression limit — and per-run medians at 10 routes spread 4.5–17.5%.
That cell is ~60 ns, where a few nanoseconds of timer and scheduling noise are a large fraction.
The ≥20% improvement at 500 routes is well clear of the noise (≤2.7% A/A, ≤16.5% spread on a
1.3–9 µs operation). Whether D4's 10-route limit applies per workload, to a mean across workloads,
or needs more runs is an owner decision; this baseline does not make it.
## End-to-end signal (`bench:compare`, req/s — not lookup time)
Run once, A/A: `AB_BASE` pointed at this same tree, so base and head are identical code. Defaults:
3 rounds × 10 s per case after a 10 s warm-up, 100 connections, alternating side order. Load
average 2.8–3.3 throughout. A few short parity-test runs (seconds each) happened during this
~22-minute run; the lookup runs above had nothing else running.
| Scenario | base req/s | head req/s | Δ |
|---|---:|---:|---:|
| hello | 88,212 | 88,236 | +0.0% |
| param | 86,508 | 85,885 | −0.7% |
| pipeline (3 steps) | 80,189 | 80,934 | +0.9% |
| steps5 | 74,359 | 73,975 | −0.5% |
| validate (POST) | 70,607 | 69,903 | −1.0% |
| hello + security | 83,913 | 83,802 | −0.1% |
| hello + cors predicate | 82,028 | 80,445 | −1.9% |
| preflight + cors predicate | 114,377 | 114,010 | −0.3% |
| param, 50 routes | 82,476 | 82,045 | −0.5% |
| param, 200 routes | 72,957 | 73,306 | +0.5% |
Every row's sample ranges overlap. So with no code change, end-to-end throughput moves up to
±1.9%; the route-width rows show that 200 filler routes already cost ~12% req/s against
`param` with none.
@@ -0,0 +1,207 @@
{
"rounds": 3,
"duration": 10,
"conns": 100,
"rows": [
{
"name": "hello",
"base": 88212.37,
"head": 88235.64,
"delta": 0.0263795202418936,
"separated": false,
"samples": {
"base": [
82493.1,
88503.28,
88212.37
],
"head": [
88177.46,
88235.64,
92826.19
]
}
},
{
"name": "param",
"base": 86507.64,
"head": 85885.1,
"delta": -0.7196358610638246,
"separated": false,
"samples": {
"base": [
81230.55,
86757.82,
86507.64
],
"head": [
83412.37,
86705.46,
85885.1
]
}
},
{
"name": "pipeline (3 steps)",
"base": 80189.1,
"head": 80933.82,
"delta": 0.9287047740902455,
"separated": false,
"samples": {
"base": [
76116.37,
80189.1,
80276.37
],
"head": [
77035.64,
80992,
80933.82
]
}
},
{
"name": "steps5",
"base": 74359.28,
"head": 73975.28,
"delta": -0.5164116704734096,
"separated": false,
"samples": {
"base": [
75272.73,
74359.28,
73928.73
],
"head": [
72235.64,
74813.1,
73975.28
]
}
},
{
"name": "validate (POST)",
"base": 70606.55,
"head": 69902.55,
"delta": -0.997074634010584,
"separated": false,
"samples": {
"base": [
70775.28,
70606.55,
69762.91
],
"head": [
67138.91,
74353.46,
69902.55
]
}
},
{
"name": "hello + security",
"base": 83912.73,
"head": 83802.19,
"delta": -0.13173209833596597,
"separated": false,
"samples": {
"base": [
81928.73,
84709.82,
83912.73
],
"head": [
81742.55,
83802.19,
84512
]
}
},
{
"name": "hello + cors predicate",
"base": 82027.64,
"head": 80445.1,
"delta": -1.9292765219138253,
"separated": false,
"samples": {
"base": [
82481.46,
82027.64,
81381.82
],
"head": [
79368.73,
82213.82,
80445.1
]
}
},
{
"name": "preflight + cors predicate",
"base": 114376.73,
"head": 114010.19,
"delta": -0.3204672838609686,
"separated": false,
"samples": {
"base": [
114580.37,
114376.73,
112322.91
],
"head": [
109669.82,
114813.1,
114010.19
]
}
},
{
"name": "param, 50 routes",
"base": 82475.64,
"head": 82045.1,
"delta": -0.5220208051734956,
"separated": false,
"samples": {
"base": [
82562.91,
82475.64,
82178.91
],
"head": [
78891.64,
82045.1,
82388.37
]
}
},
{
"name": "param, 200 routes",
"base": 72957.1,
"head": 73306.19,
"delta": 0.47848667230467834,
"separated": false,
"samples": {
"base": [
72986.19,
72957.1,
72194.91
],
"head": [
72055.28,
73306.19,
73381.82
]
}
}
],
"cors": {
"base": {
"get": 1,
"preflight": 1
},
"head": {
"get": 1,
"preflight": 1
}
}
}
@@ -0,0 +1,60 @@
[compare] round 1 base hello 82,493 req/s
[compare] round 1 base param 81,231 req/s
[compare] round 1 base pipeline (3 steps) 76,116 req/s
[compare] round 1 base steps5 75,273 req/s
[compare] round 1 base validate (POST) 70,775 req/s
[compare] round 1 base hello + security 81,929 req/s
[compare] round 1 base hello + cors predicate 82,481 req/s
[compare] round 1 base preflight + cors predicate 114,580 req/s
[compare] round 1 base param, 50 routes 82,563 req/s
[compare] round 1 base param, 200 routes 72,986 req/s
[compare] round 1 head hello 88,177 req/s
[compare] round 1 head param 83,412 req/s
[compare] round 1 head pipeline (3 steps) 77,036 req/s
[compare] round 1 head steps5 72,236 req/s
[compare] round 1 head validate (POST) 67,139 req/s
[compare] round 1 head hello + security 81,743 req/s
[compare] round 1 head hello + cors predicate 79,369 req/s
[compare] round 1 head preflight + cors predicate 109,670 req/s
[compare] round 1 head param, 50 routes 78,892 req/s
[compare] round 1 head param, 200 routes 72,055 req/s
[compare] round 2 head hello 88,236 req/s
[compare] round 2 head param 86,705 req/s
[compare] round 2 head pipeline (3 steps) 80,992 req/s
[compare] round 2 head steps5 74,813 req/s
[compare] round 2 head validate (POST) 74,353 req/s
[compare] round 2 head hello + security 83,802 req/s
[compare] round 2 head hello + cors predicate 82,214 req/s
[compare] round 2 head preflight + cors predicate 114,813 req/s
[compare] round 2 head param, 50 routes 82,045 req/s
[compare] round 2 head param, 200 routes 73,306 req/s
[compare] round 2 base hello 88,503 req/s
[compare] round 2 base param 86,758 req/s
[compare] round 2 base pipeline (3 steps) 80,189 req/s
[compare] round 2 base steps5 74,359 req/s
[compare] round 2 base validate (POST) 70,607 req/s
[compare] round 2 base hello + security 84,710 req/s
[compare] round 2 base hello + cors predicate 82,028 req/s
[compare] round 2 base preflight + cors predicate 114,377 req/s
[compare] round 2 base param, 50 routes 82,476 req/s
[compare] round 2 base param, 200 routes 72,957 req/s
[compare] round 3 base hello 88,212 req/s
[compare] round 3 base param 86,508 req/s
[compare] round 3 base pipeline (3 steps) 80,276 req/s
[compare] round 3 base steps5 73,929 req/s
[compare] round 3 base validate (POST) 69,763 req/s
[compare] round 3 base hello + security 83,913 req/s
[compare] round 3 base hello + cors predicate 81,382 req/s
[compare] round 3 base preflight + cors predicate 112,323 req/s
[compare] round 3 base param, 50 routes 82,179 req/s
[compare] round 3 base param, 200 routes 72,195 req/s
[compare] round 3 head hello 92,826 req/s
[compare] round 3 head param 85,885 req/s
[compare] round 3 head pipeline (3 steps) 80,934 req/s
[compare] round 3 head steps5 73,975 req/s
[compare] round 3 head validate (POST) 69,903 req/s
[compare] round 3 head hello + security 84,512 req/s
[compare] round 3 head hello + cors predicate 80,445 req/s
[compare] round 3 head preflight + cors predicate 114,010 req/s
[compare] round 3 head param, 50 routes 82,388 req/s
[compare] round 3 head param, 200 routes 73,382 req/s
@@ -0,0 +1,21 @@
> @green-tea/core@26.9.0-beta.2 bench:compare
> tsx bench/compare.ts
| Scenario | base | head | Δ | |
| --- | --- | --- | --- | --- |
| hello | 88,212 | 88,236 | +0.0% | overlaps |
| param | 86,508 | 85,885 | -0.7% | overlaps |
| pipeline (3 steps) | 80,189 | 80,934 | +0.9% | overlaps |
| steps5 | 74,359 | 73,975 | -0.5% | overlaps |
| validate (POST) | 70,607 | 69,903 | -1.0% | overlaps |
| hello + security | 83,913 | 83,802 | -0.1% | overlaps |
| hello + cors predicate | 82,028 | 80,445 | -1.9% | overlaps |
| preflight + cors predicate | 114,377 | 114,010 | -0.3% | overlaps |
| param, 50 routes | 82,476 | 82,045 | -0.5% | overlaps |
| param, 200 routes | 72,957 | 73,306 | +0.5% | overlaps |
cors.origins calls — base: 1 per GET, 1 per preflight
cors.origins calls — head: 1 per GET, 1 per preflight
exit 0
+6
View File
@@ -0,0 +1,6 @@
uptime before: 17:01 up 9 days, 7:50, 1 user, load averages: 2.47 2.14 6.86
uptime after: 17:02 up 9 days, 7:51, 1 user, load averages: 2.58 2.21 6.64
A/A uptime before: 17:02 up 9 days, 7:51, 1 user, load averages: 3.42 2.40 6.66
A/A uptime after: 17:03 up 9 days, 7:53, 1 user, load averages: 2.89 2.48 6.26
bench:compare uptime before: 17:04 up 9 days, 7:53, 1 user, load averages: 2.98 2.51 6.25
bench:compare uptime after: 17:26 up 9 days, 8:15, 1 user, load averages: 2.82 3.32 4.29
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,33 @@
> @green-tea/core@26.9.0-beta.2 bench:lookup
> tsx bench/lookup.ts
| router | routes | workload | median ns/op | run medians (ns) | run spread |
| --- | --- | --- | --- | --- | --- |
| live | 10 | static hit | 62.0 | 57.9 / 65.8 / 60.3 / 62.7 / 61.8 | 12.7% |
| live | 10 | late param hit | 123.8 | 124.0 / 120.4 / 122.1 / 124.3 / 128.4 | 6.4% |
| live | 10 | method miss | 309.0 | 305.7 / 305.6 / 320.1 / 310.8 / 311.6 | 4.7% |
| live | 10 | path miss | 248.4 | 242.7 / 242.5 / 253.7 / 251.0 / 248.7 | 4.5% |
| live | 100 | static hit | 69.5 | 66.7 / 68.7 / 69.2 / 71.6 / 71.5 | 7.1% |
| live | 100 | late param hit | 352.2 | 345.1 / 348.3 / 349.9 / 355.2 / 365.1 | 5.7% |
| live | 100 | method miss | 1265.3 | 1273.8 / 1256.0 / 1254.2 / 1279.7 / 1267.1 | 2.0% |
| live | 100 | path miss | 1464.9 | 1462.8 / 1451.3 / 1462.3 / 1485.2 / 1470.6 | 2.3% |
| live | 500 | static hit | 67.8 | 67.2 / 66.9 / 68.1 / 69.3 / 67.7 | 3.4% |
| live | 500 | late param hit | 1313.7 | 1362.0 / 1293.9 / 1309.7 / 1313.7 / 1316.9 | 5.2% |
| live | 500 | method miss | 6778.2 | 7068.9 / 6783.2 / 6634.3 / 6816.4 / 6689.2 | 6.4% |
| live | 500 | path miss | 9005.3 | 9445.9 / 9015.5 / 8965.0 / 9032.4 / 8834.1 | 6.8% |
| oracle | 10 | static hit | 65.2 | 62.2 / 66.6 / 66.6 / 65.2 / 58.0 | 13.1% |
| oracle | 10 | late param hit | 123.9 | 130.7 / 123.5 / 125.2 / 122.9 / 120.1 | 8.5% |
| oracle | 10 | method miss | 312.7 | 311.4 / 314.2 / 312.2 / 316.8 / 309.1 | 2.4% |
| oracle | 10 | path miss | 249.0 | 248.6 / 253.1 / 247.3 / 249.0 / 248.9 | 2.3% |
| oracle | 100 | static hit | 69.4 | 69.5 / 71.1 / 69.8 / 67.5 / 66.7 | 6.4% |
| oracle | 100 | late param hit | 349.3 | 347.5 / 352.5 / 349.6 / 347.2 / 354.0 | 1.9% |
| oracle | 100 | method miss | 1263.6 | 1294.1 / 1243.1 / 1251.2 / 1286.5 / 1258.0 | 4.0% |
| oracle | 100 | path miss | 1466.2 | 1511.6 / 1464.0 / 1459.5 / 1480.7 / 1449.1 | 4.3% |
| oracle | 500 | static hit | 66.0 | 67.0 / 67.3 / 65.8 / 64.9 / 65.1 | 3.6% |
| oracle | 500 | late param hit | 1317.6 | 1313.2 / 1310.2 / 1323.5 / 1294.5 / 1363.2 | 5.2% |
| oracle | 500 | method miss | 6753.3 | 6717.3 / 6758.7 / 6666.4 / 6876.3 / 6750.7 | 3.1% |
| oracle | 500 | path miss | 9015.3 | 8998.0 / 9021.6 / 8980.8 / 9100.7 / 8884.0 | 2.4% |
load average: start 3.42 2.40 6.66, end 2.89 2.48 6.26
raw samples: bench/baseline/router-ed47836/lookup-aa-raw.json
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,21 @@
> @green-tea/core@26.9.0-beta.2 bench:lookup
> tsx bench/lookup.ts
| router | routes | workload | median ns/op | run medians (ns) | run spread |
| --- | --- | --- | --- | --- | --- |
| live | 10 | static hit | 61.3 | 64.4 / 61.0 / 68.4 / 58.0 / 57.6 | 17.5% |
| live | 10 | late param hit | 123.3 | 122.4 / 128.1 / 123.3 / 123.7 / 120.4 | 6.2% |
| live | 10 | method miss | 313.1 | 303.2 / 314.0 / 317.6 / 317.2 / 304.7 | 4.6% |
| live | 10 | path miss | 247.1 | 243.8 / 246.0 / 256.5 / 251.7 / 239.7 | 6.8% |
| live | 100 | static hit | 67.6 | 67.6 / 70.3 / 71.7 / 66.9 / 66.3 | 8.0% |
| live | 100 | late param hit | 343.4 | 339.7 / 345.5 / 346.8 / 343.0 / 341.0 | 2.1% |
| live | 100 | method miss | 1263.7 | 1253.2 / 1236.5 / 1280.9 / 1261.0 / 1264.6 | 3.5% |
| live | 100 | path miss | 1463.3 | 1444.6 / 1442.4 / 1489.2 / 1467.6 / 1467.1 | 3.2% |
| live | 500 | static hit | 67.8 | 69.7 / 68.1 / 68.2 / 64.6 / 65.1 | 7.5% |
| live | 500 | late param hit | 1326.8 | 1480.6 / 1262.0 / 1309.9 / 1328.9 / 1331.8 | 16.5% |
| live | 500 | method miss | 6732.2 | 7072.0 / 6659.6 / 6796.0 / 6631.5 / 6699.6 | 6.5% |
| live | 500 | path miss | 8973.4 | 8915.3 / 8994.7 / 9052.0 / 8876.0 / 8981.4 | 2.0% |
load average: start 2.47 2.14 6.86, end 2.58 2.21 6.64
raw samples: bench/baseline/router-ed47836/lookup-raw.json