Skip to content

perf(mesh): win back the mesh RPC throughput #97 cost - #116

Merged
chrnx-dev merged 3 commits into
developfrom
perf/mesh-rpc-overhead
Nov 30, 2026
Merged

chrnx-dev merged 3 commits into
developfrom
perf/mesh-rpc-overhead

Conversation

@chrnx-dev

Copy link
Copy Markdown
Contributor

Regression benchmark for the week-1 mesh work (#95–#98, merged in #112–#115), and the fix for what it found. Full method and tables: bench/results/mesh-week1-46e0bc9-20f5094/README.md.

What the A/B found (jarvis, Docker node:22, cpuset 6,7,14,15)

Fix

  • The pending entry holds plain fields (started, correlation), and a plain function builds the mesh:rpc / mesh:rpc:error payload.
  • A call is timed only when something listens to mesh:rpc or mesh:rpc:error, so an app without a metrics listener pays nothing.
  • One {bus, url} per link, not per call. The teapot decrements its in-flight counter in handleRpc's finally instead of chaining .finally().
  • Events are unchanged: same fields, same tests (test/mesh/events.test.ts).

After the fix (base 46e0bc9 vs this branch, mesh only)

Runtime Rounds Δ
Node 5 × 10 s +0.6% overlaps
Deno 5 × 5 s −1.4% overlaps
Bun 5 × 5 s −0.6% overlaps

Not measured: mesh RPC with a mesh:rpc listener attached (the metrics-plugin case pays one timing pair and one payload per call, by design), route proxying over the mesh, and WebSocket.

Also in this PR

bench/compare.ts and bench/servers/compare.ts gain the mesh case (GT_MESH=1).

Verified locally

lint, format, complexity, typecheck, typecheck:bench, coverage, build, api:check, test:deno (71), test:bun (61), test:edge.

GT_MESH=1 boots a teapot in the server process that exports one step and a
teacup route that needs it. No A/B case covered the mesh RPC path before.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The week-1 regression A/B on jarvis measured mesh rpc at -4.3% on Node, -6.3% on
Deno and -2.7% on Bun (ranges separated; Node A/A -1.2%). Bisecting the merges
put all of it on #97, and swapping files back put it on src/mesh/link.ts: a
closure and a performance.now() per call to build an event payload.

The pending entry now holds plain fields (started, correlation) and a plain
function builds the payload. A call is timed only when something listens to
mesh:rpc or mesh:rpc:error, so apps without a metrics listener pay nothing.
Also: one {bus, url} per link instead of per call, and the teapot decrements
its in-flight counter in handleRpc's finally instead of chaining .finally().

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
@chrnx-dev
chrnx-dev merged commit 42e1edc into develop Nov 30, 2026
5 checks passed
@chrnx-dev
chrnx-dev deleted the perf/mesh-rpc-overhead branch November 30, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant