[zeromq-dev] Message batching in zmq

Doron Somech somdoron at gmail.com
Mon Aug 12 12:12:50 CEST 2019

It is not waiting to batch up.
The background IO thread dequeue messages from internal queue of messages
waiting to be sent.
Zeromq dequeue messages until that queue is empty or the buffer is full, so
not waiting for anything.

If we would support the zerocopy we can make the buffer larger than 8kb,
and when the buffer is full we would use the zerocopy flag.
Another option is to use the zerocopy flag only for messages larger than
8kb, whenever the engine encounters such a message it not using the buffer
and send the message directly on the wire.

The code for the batching is both on the stream_engine_base and v2_encoder
(and encoder_base).

On Mon, Aug 12, 2019 at 12:37 PM Francesco <francesco.montorsi at gmail.com>

> Hi Doron,
> Il giorno dom 11 ago 2019 alle ore 15:14 Doron Somech
> <somdoron at gmail.com> ha scritto:
> > Actually, zeromq is not waiting for buffers to be filled, the engine
> batch as much messages as possible (or until the buffer is full).
> >
> > If msg is larger than the buffer the message will be sent as is, using
> the message own buffer (zerocopy can benefit here as well).
> > We will have to free the message buffer or continue batching only after
> the kernel free the buffer.
> ok, thanks for the clarification. I guess that what you are describing
> is the code at
>   zmq::stream_engine_base_t::out_event()
> right?
> It's not totally clear to me by reading that code but I'm no way
> expert of ZMQ internals :)
> I just wonder if I can get some statistics of how much batching is ZMQ
> actually doing... my feeling is that it's not doing much... because as
> I wrote in my other email: 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?
> Thanks,
> Francesco
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20190812/befae225/attachment.htm>

More information about the zeromq-dev mailing list