Payload scaling chart: Photon Ring same-thread and cross-thread latency across 8B-4KiB payloads

Environment

MachineCPUOSRust
A (primary)Intel Core i7-10700KF @ 3.80 GHzLinux 6.81.93.1
B (secondary)Apple M1 PromacOS 26.31.92.0

Framework: Criterion, 100 samples, 3-second warmup, ring size 4096 slots.

Same-Thread Roundtrip

L1-hot, measures pure instruction cost with no cache-coherence traffic.

PayloadLatency (A)Latency (B)Cache linesNotes
8 B2.4 ns8.6 ns1Stamp + value share one 64B line
16 B9.8 ns11.3 ns1
32 B11.8 ns13.0 ns1
64 B18.8 ns16.4 ns2Slot = 72B, spills to 2 lines
128 B23.3 ns25.4 ns3
256 B34.4 ns41.2 ns5
512 B55.9 ns69.6 ns9
1 KB88.1 ns127.9 ns17memcpy starts to dominate
2 KB149.6 ns244.6 ns33
4 KB361.6 ns500.9 ns65~5.6 ns per cache line

Cross-Thread Roundtrip

Methodology note: The 117 ns at 8B here vs 95 ns in the main benchmarks reflects differences in Criterion warm-up, iterator structure, and type-generic overhead. Only Photon Ring is measured; blank cells are payload sizes not run on machine A.
PayloadPhoton Ring (A)Photon Ring (B)
8 B117 ns156.7 ns
64 B125 ns195.8 ns
256 B148 ns156.7 ns
512 B163 ns167.6 ns
1 KB191 ns226.5 ns
4 KB342 ns369.7 ns
Latency vs Payload Size (Intel i7-10700KF)
Photon Ring same-thread vs cross-thread. Log x-axis.

Key Observations

The memcpy is cheap relative to cache coherence

For payloads up to 56 bytes (one cache line with the stamp), the memcpy costs roughly 2–3 ns against a ~96 ns cache-coherence transfer. The copy is roughly 3% of total latency.

Why copy-based delivery stays competitive at large payloads

A common expectation is that an in-place design (write and read the slot directly, no copy) should beat a copy-on-publish/copy-on-receive approach at large payloads. We have not benchmarked a competitor across these sizes, so this is analysis rather than a measured result — but the copy is not the dominant cost:

  1. Cache coherence dominates, and any design pays it. Consumers must transfer the modified cache lines from the publisher regardless of whether they read in-place or copy out.
  2. x86 memcpy is extremely efficient. rep movsb with ERMS (Enhanced REP MOVSB) reaches near-memory-bandwidth speeds; a 4 KB copy costs on the order of ~200 ns, small next to the multi-line coherence transfer it rides alongside.
  3. The stamp-only fast path has low fixed overhead. No shared sequence barrier load or handler dispatch on the read side.

Regenerating

cargo bench --bench payload_scaling
python3 scripts/plot_payload_scaling.py