[nanomsg] Re: ipc benchmark nanomsg vs zeromq

  • From: Garrett D'Amore <garrett@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 14 Mar 2016 09:25:42 -0700

Nanomsg has a higher impact because it uses a whole extra set of system calls 
on a notification file descriptor. This is necessary in order to provide the 
UNIX poll/select compatible semantic.  Zmq doesn't offer this semantic and so 
it can skip quite a lot of extra work. 

Sent from my iPhone

On Mar 14, 2016, at 6:30 AM, Vaittinen, Ville (GE Healthcare) 
<ville.vaittinen@xxxxxx> wrote:

Hello,
 
I have evaluated different IPC mechanisms and one part of that was 
performance comparison.
One parameter that we checked was cpu-clock measured with standard perf tool 
on linux.
 
In the test setup we set up a simplest possible PUB/SUB scenario and was 
surprised by the result
that with nanomsg we get significantly higher perf figures (higher overhead) 
than with zero mq.
Furthermore we had defined a couple of test scenarios based on throughput and
and the perf figures seem to vary with message load as follows:
 
low (~10 kB/s) throughput 40%
medium (30 kB/s) throughput 30%
high (3 Mb/s) throughput 16%
 
In each case the percentage shows the relative cpu-clock value over the one 
measured for zero mq.
 
The reason why I ask that we had the assumption that both libraries would be 
fairly
close to each other in terms of performance. Are we maybe doing something 
wrong in our
usage of nanomsg or do these results appear plausible to anyone who has more 
in-depth knowledge
of the implementation details.
 
best regards
Ville Vaittinen
 
NANOMSG  SEND:
    int m_socket = nn_socket (AF_SP, NN_PUB);
    nn_bind (m_socket, "tcp://*:22222");
 
    while(true)
    {
        char buf[20];
        snprintf(buf, 20, "hello world testing");
 
        nn_send (m_socket, buf, 20, 0);
 
NANOMSG RECEIVE:
 
    int RECV_TIMEOUT_MS = 100;
    int sock = nn_socket (AF_SP, NN_SUB);
 
    nn_setsockopt (sock, NN_SUB, NN_SUB_SUBSCRIBE, "", 0);
    nn_setsockopt (sock, NN_SOL_SOCKET, NN_RCVTIMEO, &RECV_TIMEOUT_MS, 
sizeof(RECV_TIMEOUT_MS));
 
    if(nn_connect (sock, "tcp://localhost:22222") < 0)
    {
        return -1;
    }
 
    while (true)
    {
        int bytes = nn_recv (sock, buf, 20, 0);
    }
 
 
ZEROMQ SEND:
 
    zmq::context_t context (1);
    zmq::socket_t publisher (context, ZMQ_PUB);
    publisher.bind("tcp://*:22222");
 
    while(true)
    {
        zmq::message_t msg(20);
        snprintf((char*) msg.data(), 20, "hello world testing");
        publisher.send(msg);
 
 
ZEROMQ RECEIVE:
 
    zmq::context_t context (1);
 
    zmq::socket_t socket(context, ZMQ_SUB);
   
    socket.connect("tcp://localhost:22222");
    socket.setsockopt(ZMQ_SUBSCRIBE, 0, 0);
    socket.setsockopt(ZMQ_RCVTIMEO, RECV_TIMEOUT_MS);
 
    while (true)
    {
        zmq::message_t msg;
        if (socket.recv(&msg))
        {
 
        }

Other related posts: