TwoBufQueue
Small producer buffers. Batch copying. Independent callbacks.
Small producer buffers, with consumer capacity for pending work.
Project overviewChinese overview
C++20Apache-2.0Measured on Apple M3Parameters and raw evidence includedHow does a continuous message batch affect business performance?
Normal business → send a batch → immediate business · 2–16 MiB
Open report →WriteSessionSingle-block write loop
256 MiB · empty callback · 3 independent runs
Open report →Publication at block handoffOrdinary write: maximum publication count
256 MiB · empty callback · 3 independent runs
Open report →Publication every recordOrdinary write: publish every record
256 MiB · empty callback · 3 independent runs
Open report →Business performance after continuous sending
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)
- performance 256m callback
- performance 256m callback session
- performance 8m 16b 32b 64b tuned
- performance 8m 16b 32b tuned
- performance 8m 32b latency
- performance 8m zero
- performance 8m zero session
- performance burst business sizes
- performance burst tail 1m
- performance burst tail instruction 1m
- performance hot path cache
- performance optimal ordinary readback reader2g zero
- performance optimal three modes reader2g zero
- test per write block size only writer publish1
- test per write block size only writer publish max
- test per write block size only writer reader80 3runs publish1
- test per write block size only writer reader80 3runs publish max
- test per write block size readback fixed reader 3runs
- test per writer block size
- test per writer block size cache hits
- test per writer block size max comparison 3runs
- test per writer block size no current
- test per writer block size no current publish1
- test per writer block size reader80 3runs max