[zeromq-dev] ZMQ Performance

Martin Sustrik sustrik at fastmq.com
Tue Jul 28 13:04:01 CEST 2009


Sorry for delay. Your mail have been stuck at the mailing server as only 
those subscribed to the list are allowed to post.

> I have just started to test the c++ and c# implementations of zeromq.  I 
> have been running simple test to determine the relative
> speed of each implementation with respect to each other and to different 
> message sizes.  Before I begin to tune my settings, I wanted
> to see if I could confirm two of my findings regarding throughput with 
> others have made this comparison.
> I began testing different message lengths with each implementation and 
> with the c++ soon found that there was a serious drop-off,
> which I found to be 30 bytes.  I ran the following byte lengths, each 5 
> times and took the average, and got the following table:
> Language        Message Length      Messages/sec
> C++                        28                      1.52 million
> C++                        29                      1.59 million        
> C++                        30                      1.5 million
> C++                        31                       .86 million
> C++                        32                       .83
> C#                        28                      .474 million
> C#                        29                      .450 million        
> C#                        30                      .446 million
> C#                        31                       .360 million
> C#                        32                       .345 million
> So my questions are:
> 1. Is it accurate to say that the c++ library is about 3x as fast as the C#?

That very much depends on the stack you are using including hardware, OS 
etc. In any case you should expect C# to be slower than C++. The reason 
is that C# handles object allocation/deallocation automatically and thus 
it makes it impossible for 0MQ to optimise message 
allocation/deallocation strategies. Allocation/deallocation becomes a 
bottleneck of the system.

> 2. Is the steep drop-off after 30 bytes caused by obvious TCP setting,
>     and if so why does the c++ library lose over 40% and the C# only 20%?

Have a look at libzmq/zmq/config.hpp:

//  Maximal size of "Very Small Message". VSMs are passed by value
//  to avoid excessive memory allocation/deallocation.
max_vsm_size = 30,

This line means that there's no allocation going on for messages shorter 
than 30 bytes. Larger messages are allocated on the heap to avid 
excessive copying. 30 seems to be right threshhold for big boxes (8 core 
3GHz or alike). On your system, setting max_vsm_size to a larger value 
may make sense.


More information about the zeromq-dev mailing list