Skip to main content

Cost

What the framework's own code costs per message, measured in instructions and allocations, and where the cost goes.

Instructions and allocations per message

AMD Ryzen 9 7900X 12-Core Processor, x86_64 (x86-64-v4), base unknown, min 427 MHz, max 5912 MHz, 12 physical, 24 logical, 62.4 GiB, unknown, Linux 7.3.0-3-moloko, 1.99.1, 3.25.1, bench, inheriting release (opt-level = 3, lto = fat, codegen-units = 16, debug = line-tables-only), --no-default-features --features memory,macros,json,tokio. ruststream 0.8.0, measured 2026-11-01.

Instructions
Allocations
consume, JSON decode into a small struct
1,697.4
0
consume, JSON decode of a 1 KB body
17,304.2
0
consume on the byte lane, no codec
862.4
0
consume through a pool of four workers
3,131.8
0
consume on four dedicated threads
461.4
0
consume through a middleware stack of one
1,742.3
0
consume through a middleware stack of four
1,785.3
0
consume in batches of 64
1,516.2
0
consume in batches of 64 through a pool of four workers
1,538.8
0
reply, encoded to a declared destination
2,583.4
1
reply to a transport that reads the payload
2,051.4
0
publish through an Out slot with one transform
3,143.4
2
publish through an Out slot to a transport that reads the payload
2,570.4
1
publish with a typed header contract
3,589.4
4
read a typed header contract, then publish
3,972.3
1
request and reply, one round trip
8,920.9
10
a continuation left behind by every delivery
3,456.6
2
a delivery that asks to be redelivered, natively by the broker
3,270.5
0
a delayed redelivery the runtime publishes as a copy
9,531.1
6
Show the numbers as a table
ScenarioInstructionsAllocationsCold start
consume, JSON decode into a small struct1,697.4016,282 / 26
consume, JSON decode of a 1 KB body17,304.2032,028 / 26
consume on the byte lane, no codec862.4015,563 / 26
consume through a pool of four workers3,131.8029,529 / 43
consume on four dedicated threads461.4056,438 / 133
consume through a middleware stack of one1,742.3016,700 / 26
consume through a middleware stack of four1,785.3016,742 / 26
consume in batches of 641,516.2018,273 / 28
consume in batches of 64 through a pool of four workers1,538.8033,921 / 45
reply, encoded to a declared destination2,583.4118,881 / 28
reply to a transport that reads the payload2,051.4018,136 / 29
publish through an Out slot with one transform3,143.4219,056 / 29
publish through an Out slot to a transport that reads the payload2,570.4118,907 / 31
publish with a typed header contract3,589.4419,789 / 31
read a typed header contract, then publish3,972.3119,464 / 28
request and reply, one round trip8,920.91024,823 / 36
a continuation left behind by every delivery3,456.6217,781 / 28
a delivery that asks to be redelivered, natively by the broker3,270.5017,914 / 26
a delayed redelivery the runtime publishes as a copy9,531.1625,096 / 32

The numbers are the steady state per message, on the in-process broker, so no transport is in them. A row shows its cold start on hover or focus: what starting the service and handling the first delivery cost together, paid once.

Taking a delivery allocates nothing. The loop keeps one slot for the delivery and one encode buffer, and every stage is a generic type resolved at compile time, with no dynamic call on the way. A DynStack of layers chosen at run time costs one boxed future per layer per message. An and_after continuation is one boxed future, paid only by the delivery that sets it.

A reply allocates nothing when the broker's client only reads the bytes: it is lent the loop's buffer. The in-process broker keeps what it is handed, so its reply costs the buffer the codec wrote. The other publish rows allocate what the in-process broker keeps of each message, and what the scenario builds itself: a header value, or a request's single-use inbox.

The payload's size is the expensive part of a decode: compare the 1 KB body with the small struct. The benchmarks publish every scenario with its method, against each broker's raw client too.