Cost
What the framework's own code costs per message, measured in instructions and allocations, and where the cost goes.
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, 4800 MT/s, 6000 MT/s, DDR5, Linux 7.2.9-x64v3-xanmod1-1, 1.99.0, 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. ruststream 0.7.0, measured 2026-10-06.
Show the numbers as a table
| Scenario | Instructions | Allocations | Cold start |
|---|---|---|---|
| consume, JSON decode into a small struct | 1,673 | 0 | 15,079 / 26 |
| consume, JSON decode of a 1 KB body | 17,402.8 | 0 | 30,936 / 26 |
| consume on the byte lane, no codec | 826 | 0 | 14,192 / 26 |
| consume through a pool of four workers | 3,092.1 | 0 | 27,005 / 43 |
| consume on four dedicated threads | 457.1 | 0 | 55,119 / 133 |
| consume through a middleware stack of one | 1,723 | 0 | 15,205 / 26 |
| consume through a middleware stack of four | 1,768 | 0 | 15,252 / 26 |
| consume in batches of 64 | 1,529.5 | 0 | 16,432 / 29 |
| reply, encoded to a declared destination | 2,641 | 2 | 16,787 / 29 |
| reply to a transport that reads the payload | 2,106 | 0 | 16,294 / 29 |
| publish through an Out slot with one transform | 3,768 | 6 | 18,540 / 33 |
| publish with a typed header contract | 3,632 | 5 | 17,990 / 32 |
| read a typed header contract, then publish | 4,004.9 | 2 | 17,762 / 29 |
| request and reply, one round trip | 9,361.6 | 13 | 23,358 / 39 |
| a delivery that asks to be redelivered, natively by the broker | 3,157.7 | 0 | 16,662 / 26 |
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.