[zeromq-dev] Message batching in zmq

Francesco francesco.montorsi at gmail.com
Mon Aug 12 11:27:21 CEST 2019

Hi Luca,

Il giorno dom 11 ago 2019 alle ore 13:00 Luca Boccassi
<luca.boccassi at gmail.com> ha scritto:
> Batching happens in the engine - the default data size is 8KB, tuned
> via src/config.hpp - although it's extremely tricky and it's very very
> easy to shot on oneself's foot by changing those parameters.

Well I digged a little more in the source code and apparently that 8KB
value is written in the
structure and initialized in "options.cpp" and can be even modified
using the zmq_setsockopt() using the ZMQ_OUT_BATCH_SIZE undocumented
I guess the fact it's undocumented at
is because of the fact that, as you say, it's easy to shoot on oneself's foot

> Tweaking those can be done, but it needs a very very well defined test
> setup with a precise workload, which we don't really have.
> Yes adjusting the heuristics for MSG_ZEROCOPY is one of the TODOs to be
> able to use it effectively.
ok I see.

Still I don't understand one thing.
If the sockets in the benchmark utilities local_thr/remote_thr are
using that default 8KB value, then shouldn't I see an almost-flat
curve in this graph
in the message size range [0-8KB] ?

I mean: if ZMQ engine is indeed waiting to batch up to 8KB of data
before going down the Linux kernel stack via send() API, all the
difference between sending 256B frames and 8KB frames is just the
overhead of ZMQ engine for doing that batching?
What am I missing?


More information about the zeromq-dev mailing list