Thanks Doron!
I guess this post from Pieter is a good backgrounder as well:
http://hintjens.com/blog:84
On 5/16/19 7:49 PM, Doron Somech wrote:
Over inproc zeromq need to signal the other thread (if asleep, no
waiting messages) that a message is ready to be consumed. Internally
zeromq is using a file descriptor for that.
However, with thread-safe sockets, a mutex and conditional variable are
used for signaling so no file descriptor is used (and it doesn't go to
the kernel for most cases, so some way faster).
CLIENT-SERVER, RADIO-DISH, and GATHER-SCATTER are the new thread-safe
sockets. You can use them from multiple threads. However, the catch is
that they don't support multi-part messages.
In the case of zactor, we can benefit from a thread-safe actor, which
can be called from multiple threads. However, we might need to create a
new class for that, or maybe just a constructor. zactor_new_safe?
I think the CLIENT-SERVER sockets are the best fit for the safe actor.
When it is only a command threads can share the client, but when it is a
request-response we would need to create a client per thread or client
per request, which is not that expensive as no file descriptor is created.
On Thu, May 16, 2019 at 8:32 PM Arnaud Loonstra <arn...@sphaero.org
<mailto:arn...@sphaero.org>> wrote:
Hi Doron,
Can you elaborate? I've heard about threadsafe sockets in zmq but
haven't seen them in the wild. Any pointers?
Rg,
Arnaud
On 5/16/19 6:01 PM, Doron Somech wrote:
> File descriptor is being used for signaling.
> If zactor would use thread safe sockets it would be unlimited.
>
> On Thu, May 16, 2019, 18:51 Arnaud Loonstra <arn...@sphaero.org
<mailto:arn...@sphaero.org>
> <mailto:arn...@sphaero.org <mailto:arn...@sphaero.org>>> wrote:
>
> Hi all,
>
> I'm currently stress testing a setup with actors. What's the
maximum
> number of running zactors? As it's using inproc no file
descriptors are
> involved. I'm using this test:
>
> // mega zactor test
> zlist_t *spawned_act = zlist_new();
> for (int i=0;i<507;i++)
> {
> zactor_t *act = zactor_new(echo_actor, "Hello actor");
> assert(act);
> zlist_append(spawned_act, act);
> }
> while(zlist_size(spawned_act) > 0)
> {
> zactor_t *dstr = zlist_pop(spawned_act);
> zactor_destroy(&dstr);
> }
>
> If I go beyond 507 actors I receive an assert:
>
> src/zsock.c:88: zsock_new_checked: Assertion `self->handle'
failed.
>
> Which traces back to:
>
> self->handle = zsys_socket (type, filename, line_nbr);
>
> Which is a wrapper for creating a zmq socket.
>
> Any ideas why there's is this limit of 507 actors?
>
> I also tried with my own actor library which adds pub/sub
sockets to
> the
> actor. I then have a maximum of 252 actors.
>
> Rg,
>
> Arnaud
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org <mailto:zeromq-dev@lists.zeromq.org>
<mailto:zeromq-dev@lists.zeromq.org
<mailto:zeromq-dev@lists.zeromq.org>>
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org <mailto:zeromq-dev@lists.zeromq.org>
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org <mailto:zeromq-dev@lists.zeromq.org>
https://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev