Repository navigation
Benchmark sandboxed vs trusted function dispatch, document real numbers - #136
Merged
Merged
Conversation
docs/CAPACITY.md asserted the trusted default's concurrency ceiling
("ordinary Node concurrency... no fixed worker-slot ceiling") as
architectural reasoning from the trust-model change (PR #127), never
backed by a measurement. Add benchmarks/sandbox-vs-trusted.ts, which
runs the same 20ms handler source on a sandbox:true route and a
trusted route in one server at concurrency 1/2/8/32/128, and use its
real output (benchmarks/results/2026-09-19-sandbox-vs-trusted.json) to
replace the assertion in docs/CAPACITY.md with a measured comparison
table.
The measurement confirms the architectural prediction: the sandboxed
path's 2-worker ceiling is already visible at concurrency 8 (>95%
shed, flat ~80 req/s regardless of further concurrency), while the
trusted path scales cleanly to 1,465 req/s at concurrency 32 with zero
shedding, only hitting its own ceiling (the --max-in-flight admission
cap, default 64) at concurrency 128.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
docs/CAPACITY.mddescribed the trusted-by-default path's concurrency model("ordinary Node concurrency... no fixed worker-slot ceiling... bounded by
--max-in-flight") as architectural reasoning written when the trust modelshipped (PR #127), never backed by an actual benchmark run. That's a gap
against this project's own stated ethos ("report actual evidence... CI
passing is not... deployment/soak proof").
What this does
benchmarks/sandbox-vs-trusted.ts(npm run benchmark:sandbox-vs-trusted),following the same conventions as
benchmarks/routing.ts: a privatein-process server, a keep-alive HTTP agent, a warmup phase excluded from
every statistic, then a measured burst. It runs the same handler source
(a 20 ms guest/host timer, chosen to make both ceilings visible) on a
sandbox: trueroute and a trusted route in the same server, at defaultsettings (
workers: 2,maxInFlightRequests: 64), across concurrency1/2/8/32/128, and records throughput (successful req/s), shed count and
p50/p95/p99 latency at each level.
benchmarks/results/2026-09-19-sandbox-vs-trusted.json(new location —benchmarks/agent/runs/is specifically for the agent code-generationbenchmark per its own README, not runtime perf, so this adds a small
sibling
benchmarks/results/with a README explaining the distinction).docs/CAPACITY.mdwith a new"Measured: sandboxed vs trusted dispatch" section: a real comparison table
plus prose stating plainly where each ceiling becomes visible, with
hardware/environment caveats (CPU count, Node version, one machine's
numbers, handler-shape caveat).
The actual run
Environment: Intel Xeon @ 2.10 GHz, 4 vCPUs, 16 GiB RAM, Linux x64, Node
v22.22.2, 2026-09-19.
Full JSON output is in the stored run file linked above (also
docs/CAPACITY.md's new section).What this confirms and what it doesn't
concurrency 8 in this run (already >95% shed), flat at ~80 req/s
regardless of how much more concurrency is offered — matches the
documented "2 workers, no queue" model exactly.
32 (1,465 req/s), and only starts shedding at concurrency 128 when
offered load exceeds the
--max-in-flightadmission cap (default 64,521/2000 shed at that level) — also matches the documented model.
trusted path's advantage over the sandboxed 2-worker ceiling is real and
large in this run, not smaller than predicted. I looked for evidence of
event-loop contention limiting the trusted path more than expected and
did not find it at these concurrency levels on this handler shape — worth
another look with a CPU-heavier handler, which this run doesn't cover
(its 20 ms cost is a timer, not CPU work).
routes served from one process (so the trusted numbers include whatever
contention comes from the sandboxed route also running), no TLS/proxy/
production logging. Re-run on deployment hardware with a representative
handler before sizing anything.
Verification
npm run typecheck— greennpm run lint— greennpm run check— greennpm test— 485 passed, 2 skipped (pre-existing TLS skip), 0 failednpm run build— green (dist/not committed)🤖 Generated with Claude Code
https://claude.ai/code/session_018neC2tYKPxMPbzZf1wNctr
Generated by Claude Code