[zeromq-dev] patch: handle idle connections

Martin Sustrik sustrik at fastmq.com
Wed Mar 25 09:33:55 CET 2009


> Thanks a lot for checking this.
> Yes, malloc/free will be pretty bad in req/res case.
> My tests were done over loopback on a duel core, guess they weren't
> very realistic.
> I like linked list concept, but wonder if a bitmap would work better
> to index active/idle pipes.

The bitmap is nice for the minimal number of operations you need to 
switch a pipe from active to idle state or vice versa. This is done at 
the hottest point of the critical path so each access to memory has 
measurable impact. With linked lists there would be ~6 memory operations 
per switch. With bitmap it would be a single operation.

On the other hand, the goal of this patch is to turn O(n) algorithm of 
finding next active pipe to O(1) algorithm. I'm not sure whether it can 
be achieved with bitmap. There are several clever bitmap lookup 
algorithms, however, all of them are O(n) AFAIK.


More information about the zeromq-dev mailing list