From 5fafe97bc5e4dcda96acbd49380ce30e2dc1b777 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 16 Aug 2026 23:03:07 -0500 Subject: [PATCH] docs: correct the observability cost, and record why three earlier numbers were wrong The published figure was -3.9%. It was measured sequentially rather than interleaved, and the machine drifts 12% across a session as it warms, so run order was indistinguishable from effect. Two later attempts to correct it were also wrong: 0.8% had the same flaw, and -6.8% compared 7bd11bf against HEAD, which differ by observability *and* three performance fixes pulling the other way, then reported their net as if it were one of them. Measured properly, alternating round by round between 7bd11bf and 523e318 (the last commit before those fixes): +7.0% of the framework's own per-request work, about 0.29us, roughly 2% of a request over a real socket. Ranges do not overlap. The guide no longer quotes absolute throughput from this laptop. The reference numbers come from a two-box setup, and single-box loopback figures invite a comparison that is not valid. D7's shape survives: the cost is fixed per request, not per step, because per-step work is skipped when nothing subscribes. Signed-off-by: Diego Resendez --- docs/plans/2026-08-16-observability-design.md | 4 +++- docs/plans/2026-08-16-observability-plan.md | 16 ++++++++++------ .../src/content/docs/guides/observability.md | 18 ++++++++++-------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/docs/plans/2026-08-16-observability-design.md b/docs/plans/2026-08-16-observability-design.md index ffaaf52..5f74c0f 100644 --- a/docs/plans/2026-08-16-observability-design.md +++ b/docs/plans/2026-08-16-observability-design.md @@ -149,7 +149,9 @@ Two things follow. `Date.now()` loses on both axes — slower *and* coarser — At 0.25% per step the overhead sits **below the 0.3% run-to-run CV of the project's own benchmark**, so it is not measurable in the harness that would have to justify a flag. Making it opt-in would buy two code paths and a configuration surface in exchange for something nobody can observe. Always on. -> **Correction, after implementation.** This decision survived; its reasoning did not. Measured over a real socket the cost is **−3.9% on JSON hello and −2.1% on a three-step pipeline** — the shallower route loses *more*, which is the opposite of a per-step model. Per-step work is skipped entirely when nothing subscribes; what is left is a fixed per-request cost. "Always on" is still right, and for a better reason: there is nothing per-step left to make optional. See Task 7 in the implementation plan. +> **Correction, after implementation.** This decision survived; its reasoning did not. The measured cost is **+7.0% of the framework's own per-request work** (~0.29 µs, ~2% over a real socket), and it is *fixed per request* rather than per step — per-step work is skipped entirely when nothing subscribes. "Always on" is still right, and for a better reason: there is nothing per-step left to make optional. +> +> Three earlier figures for this were published before that one and all three were wrong, each from a comparison with more than one variable moving. See Task 7 in the implementation plan for what went wrong and why interleaving is not optional here. ### D8 — Request logging is a `Bus` subscriber, wrapped so a failing logger cannot go silent diff --git a/docs/plans/2026-08-16-observability-plan.md b/docs/plans/2026-08-16-observability-plan.md index 2dead70..67a45fe 100644 --- a/docs/plans/2026-08-16-observability-plan.md +++ b/docs/plans/2026-08-16-observability-plan.md @@ -116,14 +116,18 @@ Tasks 1–3 are the correction; 4–6 are what consumes it. Do not start 4 befor **Files:** - Modify: `BENCHMARKS.md` -D7 predicted ~0.25% **per step**, invisible against the harness's own 0.3% CV. Measured over a real socket, on the box `BENCHMARKS.md` was produced on, same server config both sides: +D7 predicted ~0.25% **per step**, invisible against the harness's own 0.3% CV. -| Scenario | Before | After | | -|---|---:|---:|---:| -| JSON hello | 78,118 req/s | 75,075 req/s | −3.9% | -| Pipeline (3 steps) | 70,671 req/s | 69,164 req/s | −2.1% | +**Measured: +7.0% of the framework's own per-request work** — 4.074 µs → 4.361 µs, medians of five interleaved rounds, ranges not overlapping. About 0.29 µs, or ~2% of a request over a real socket. -**The route with fewer steps loses more**, which falsifies the model rather than only the number. The per-step cost is real but is skipped entirely when nothing subscribes (`Bus.hasListeners`); what remains is a **fixed per-request** cost — generating the request id, reading two headers, and the guard checks. A shallow route amortises that over less work, so it shows up larger. +The prediction was wrong in **shape**, not only magnitude. Per-step work is skipped entirely when nothing subscribes (`Bus.hasListeners`), so a deep pipeline pays no more than a shallow one; what remains is a **fixed per-request** cost — generating the request id, reading two headers, and the guard checks. "Always on" survives, for a better reason than it was made with: there is nothing per-step left to make optional. + +**Three earlier numbers for this were published and all three were wrong**, which is the more useful lesson: −3.9%, then 0.8%, then −6.8%. Each came from a comparison with more than one variable moving. + +- The first two were sequential rather than interleaved. The same code measured at the start and end of one session differed by **12%** as the machine warmed, so run order was indistinguishable from effect — one of them even reported the wrong sign. +- The third compared `7bd11bf` against `HEAD`, which differ by observability **and** three performance fixes pulling the other way. It reported their net as if it were one of them. + +The number above compares `7bd11bf` against `523e318`, the last commit before those fixes, alternating round by round. Two regressions were found and fixed by measuring rather than reasoning, both larger than anything the design anticipated: diff --git a/website/src/content/docs/guides/observability.md b/website/src/content/docs/guides/observability.md index 45a19fa..cc65843 100644 --- a/website/src/content/docs/guides/observability.md +++ b/website/src/content/docs/guides/observability.md @@ -131,13 +131,15 @@ instrumentation — the graph already knows every node. ## What it costs -Measured, not asserted, on the box that produced [BENCHMARKS.md](https://github.com/Expressive-Tea/green-tea/blob/main/BENCHMARKS.md): +**About 0.29 µs per request** — roughly **7% of the framework's own work**, or **~2% of a request +measured over a real socket**, where the transport dominates. -| Scenario | Before | After | | -|---|---:|---:|---:| -| JSON hello | 78,118 req/s | 75,075 req/s | −3.9% | -| Pipeline (3 steps) | 70,671 req/s | 69,164 req/s | −2.1% | +The cost is **per request, not per step**. Per-step timing and payload construction are skipped +entirely when nothing is subscribed, so a deep pipeline pays no more than a shallow one. What +remains is fixed: generating the request id, reading two headers, and the checks that decide +whether anyone is listening. -The cost is **per request, not per step** — which is why the route with *fewer* steps loses more. -Most of it is generating the request id; per-step timing and payload construction are skipped -entirely when nothing is subscribed. +Absolute throughput numbers are deliberately not quoted here. The figure above comes from an +interleaved A/B — alternating both versions round by round — because the same code measured at the +start and end of one session on the same machine differed by 12% as it warmed up. Any before/after +that does not interleave is measuring the clock as much as the code.