[zeromq-dev] [PATCH] Scalability improvements for large amounts of connections

Martin Lucina mato at kotelna.sk
Mon Oct 11 17:12:34 CEST 2010


Martin, Pieter,

sustrik at 250bpm.com said:
> On 10/11/2010 04:57 PM, Pieter Hintjens wrote:
> 
> >> In other words, you cannot use the same
> >> socket from 2 threads in parallel
> >
> > By "ensure full memory barrier" you mean that sockets are not safe to
> > use from multiple threads at the same time?
> 
> No you can't use same socket from two threads at the same time.
> 
> The memory barrier is unrelated to the above. It's a machine instruction 
> that ensures that the caches are synchronised and instruction reordering 
> doesn't happen across the barrier. That way you can be sure that 
> lock-free algorithms see a consistent data in memory after migration is 
> done.

I agree that "socket migration" should be documented. However, IMHO 99.9%
of users have no idea what a "full memory barrier" is or why they should
care. In my opinon, migrating sockets between threads is really only
something advanced users and binding implementers should be concerned with.
Everyone else should just be told to use sockets from a single thread only.

If you think that migrating sockets between threads has value for Joe User,
then shouldn't we introduce an explicit API that does that? Even if all
this hypothetical API call would do is issue a memory barrier?

-mato



More information about the zeromq-dev mailing list