[zeromq-dev] patch: handle idle connections

Martin Sustrik sustrik at fastmq.com
Wed Mar 25 15:47:59 CET 2009

>> Actually, I have an idea. The algorithm is completely domain specific, but
>> simple and very fast...
> You don't care about ordering active connections, and you have a fixed
> limit for A?  Then it would work nicely.
> There is still a problem that you'll get gaps in the A table when
> connections go inactive.  You either need to scan over holes, or
> compress.
> What I'd do is use linked lists but without memory allocation.  That
> is, you allocate a block and in that, make linked lists.  I.e. array
> of structures containing next pointer, and data.  Use two blocks, one
> for active, one for idle.  Use offset pointers (i.e. byte offset from
> start of block) rather than real memory pointers.  Then if you need to
> expand the table you reallocate and copy.
> This lets you do everything rapidly with no copying, allocation,
> scanning, compression...

That was the original idea (see the diagram at the beginning of this 
thread). It requires 6 memory accesses per flip. However, look at the 
algorithm I've proposed once more. It creates no gaps. Ever. And it 
requires only 2 memory accesses per flip.


More information about the zeromq-dev mailing list