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, 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.

Instructions
Allocations
consume, JSON decode into a small struct
1,673
0
consume, JSON decode of a 1 KB body
17,402.8
0
consume on the byte lane, no codec
826
0
consume through a pool of four workers
3,092.1
0
consume on four dedicated threads
457.1
0
consume through a middleware stack of one
1,723
0
consume through a middleware stack of four
1,768
0
consume in batches of 64
1,529.5
0
reply, encoded to a declared destination
2,641
2
reply to a transport that reads the payload
2,106
0
publish through an Out slot with one transform
3,768
6
publish with a typed header contract
3,632
5
read a typed header contract, then publish
4,004.9
2
request and reply, one round trip
9,361.6
13
a delivery that asks to be redelivered, natively by the broker
3,157.7
0
Show the numbers as a table
ScenarioInstructionsAllocationsCold start
consume, JSON decode into a small struct1,673015,079 / 26
consume, JSON decode of a 1 KB body17,402.8030,936 / 26
consume on the byte lane, no codec826014,192 / 26
consume through a pool of four workers3,092.1027,005 / 43
consume on four dedicated threads457.1055,119 / 133
consume through a middleware stack of one1,723015,205 / 26
consume through a middleware stack of four1,768015,252 / 26
consume in batches of 641,529.5016,432 / 29
reply, encoded to a declared destination2,641216,787 / 29
reply to a transport that reads the payload2,106016,294 / 29
publish through an Out slot with one transform3,768618,540 / 33
publish with a typed header contract3,632517,990 / 32
read a typed header contract, then publish4,004.9217,762 / 29
request and reply, one round trip9,361.61323,358 / 39
a delivery that asks to be redelivered, natively by the broker3,157.7016,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.