English中文

TwoBufQueue

Small producer buffers. Batch copying. Independent callbacks.
Small producer buffers, with consumer capacity for pending work.

C++20Apache-2.0Measured on Apple M3Parameters and raw evidence included
Continuous sending · each batch starts empty

How does a continuous message batch affect business performance?

Normal business → send a batch → immediate business · 2–16 MiB

Open report →
WriteSession

Single-block write loop

256 MiB · empty callback · 3 independent runs

Open report →
Publication at block handoff

Ordinary write: maximum publication count

256 MiB · empty callback · 3 independent runs

Open report →
Publication every record

Ordinary write: publish every record

256 MiB · empty callback · 3 independent runs

Open report →

Business performance after continuous sending

Business group-average p50 after continuous 2,4,8,16 MiB batches, each starting empty, with normal business at 13 ns per call

Normal business → send a continuous message batch → immediately run the same business. Every batch starts with zero pending messages; consumers stay active and draining happens outside timing. Same 48 KiB business data set, 32 B messages and 64 callback iterations. TwoBufQueue uses 16 KiB of source buffers and 256 MiB of output storage; native SPSC queues use 256 MiB of slots.

Normal business costs about 13 ns/call (dashed line). After 16 MiB: TwoBufQueue 18.2 ns/call (1.40×), ReaderWriterQueue 58.2 ns, rigtorp 42.5 ns, atomic_queue 99.8 ns. At 2 MiB, TwoBufQueue and rigtorp tie at 15.6 ns/call.

p50 of 16-call business group means, averaged across three independent runs. High producer QoS; no hard CPU affinity. Full results, ratios and initialization parameters.

Read the numbers correctly

Write reports measure producer submission cost in groups of 1,000 writes. The batch/business reports measure business execution in groups of 16 calls. Neither is individual-message or end-to-end latency. Thread counts, source/output pools and upstream payload construction choices are stated in each report; rankings apply to the recorded setup.

Methodology and reproduction · Publication contents · Publishing steps

Additional measurements and earlier experiments (Chinese records)