I was searching around, and couldn't find a easy way.. So I thought I'd ask.
I want to be able to send a message to a group of actors (10-60k of them) so I can do a simulation, like a discrete time based thing. Besides from a 'for' loop is there a better way of doing this? I was thinking of using a latch or gate-type mechanism but that seems a bit heavy to me.
---
Ian Holsman - 703 879-3128
I saw the angel in the marble and carved until I set him free -- Michelangelo
What's wrong with the loop?
Unless you have equal amounts of cores as you have actors you'll never achieve what you want. Putting a message into the mailbox and when that message is processed is completely different things.
If you need synchronizity you shouldn't use actors. Perhaps try Futures instead?
V
I think actors are more expensive than latches.You need to deal with the overhead message-invocation creation, all kinds of locks used for dispatcher, actor itself etc.Akka is not designed or meant to compete on that level.The for loop for sending of course could be parallelized. We have 'broadcast' functionality in place when the Routing is used, so you can broadcast to a bunch of actors. But currently this is not designed to deal with such a large number of recipients. So if it really is important, what you could do, is to create your own ActorRef that can be tailored made for this purpose. Perhaps even using the FJ framework of Java 7 to parallelize the broadcast.
If you want I can show you some pointers how to do it.--On Sat, Aug 6, 2011 at 6:52 AM, Ian Holsman <i...@holsman.net> wrote:
Hi.
I was searching around, and couldn't find a easy way.. So I thought I'd ask.
I want to be able to send a message to a group of actors (10-60k of them) so I can do a simulation, like a discrete time based thing. Besides from a 'for' loop is there a better way of doing this? I was thinking of using a latch or gate-type mechanism but that seems a bit heavy to me.
---
Ian Holsman - 703 879-3128
I saw the angel in the marble and carved until I set him free -- Michelangelo
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
On Sat, Aug 6, 2011 at 10:40 AM, Peter Veentjer <alarm...@gmail.com> wrote:I think actors are more expensive than latches.You need to deal with the overhead message-invocation creation, all kinds of locks used for dispatcher, actor itself etc.Akka is not designed or meant to compete on that level.The for loop for sending of course could be parallelized. We have 'broadcast' functionality in place when the Routing is used, so you can broadcast to a bunch of actors. But currently this is not designed to deal with such a large number of recipients. So if it really is important, what you could do, is to create your own ActorRef that can be tailored made for this purpose. Perhaps even using the FJ framework of Java 7 to parallelize the broadcast.
As I said, that would be completely pointless.
2011/8/6 √iktor Ҡlang <viktor...@gmail.com>On Sat, Aug 6, 2011 at 10:40 AM, Peter Veentjer <alarm...@gmail.com> wrote:I think actors are more expensive than latches.You need to deal with the overhead message-invocation creation, all kinds of locks used for dispatcher, actor itself etc.Akka is not designed or meant to compete on that level.The for loop for sending of course could be parallelized. We have 'broadcast' functionality in place when the Routing is used, so you can broadcast to a bunch of actors. But currently this is not designed to deal with such a large number of recipients. So if it really is important, what you could do, is to create your own ActorRef that can be tailored made for this purpose. Perhaps even using the FJ framework of Java 7 to parallelize the broadcast.
As I said, that would be completely pointless.Thank you!It all depends on what the goal is. If the sending thread should not be busy too long for sending messages to all the recipient, parallelizing the send of all messages is going to deliver a scalability improvement.And in case of sending 50k messages, I certainly is something worth considering.
Thanks for the advice guys... I'll check out the FJ stuff in Java 7, and go back to latches.
On Sat, Aug 6, 2011 at 11:45 AM, Peter Veentjer <alarm...@gmail.com> wrote:2011/8/6 √iktor Ҡlang <viktor...@gmail.com>On Sat, Aug 6, 2011 at 10:40 AM, Peter Veentjer <alarm...@gmail.com> wrote:I think actors are more expensive than latches.You need to deal with the overhead message-invocation creation, all kinds of locks used for dispatcher, actor itself etc.Akka is not designed or meant to compete on that level.The for loop for sending of course could be parallelized. We have 'broadcast' functionality in place when the Routing is used, so you can broadcast to a bunch of actors. But currently this is not designed to deal with such a large number of recipients. So if it really is important, what you could do, is to create your own ActorRef that can be tailored made for this purpose. Perhaps even using the FJ framework of Java 7 to parallelize the broadcast.
As I said, that would be completely pointless.Thank you!It all depends on what the goal is. If the sending thread should not be busy too long for sending messages to all the recipient, parallelizing the send of all messages is going to deliver a scalability improvement.And in case of sending 50k messages, I certainly is something worth considering.
Adding an entry into a ConcurrentLinkedQueue is in the nanosecond space.
On Sat, Aug 6, 2011 at 12:54 PM, Ian Holsman <i...@holsman.net> wrote:Thanks for the advice guys... I'll check out the FJ stuff in Java 7, and go back to latches.
I still don't understand why it's important for all actors to start processing the message at the same time, they need a thread to process the message anyway, and you don't have 50000 cores...
2011/8/6 √iktor Ҡlang <viktor...@gmail.com>On Sat, Aug 6, 2011 at 11:45 AM, Peter Veentjer <alarm...@gmail.com> wrote:2011/8/6 √iktor Ҡlang <viktor...@gmail.com>On Sat, Aug 6, 2011 at 10:40 AM, Peter Veentjer <alarm...@gmail.com> wrote:I think actors are more expensive than latches.You need to deal with the overhead message-invocation creation, all kinds of locks used for dispatcher, actor itself etc.Akka is not designed or meant to compete on that level.The for loop for sending of course could be parallelized. We have 'broadcast' functionality in place when the Routing is used, so you can broadcast to a bunch of actors. But currently this is not designed to deal with such a large number of recipients. So if it really is important, what you could do, is to create your own ActorRef that can be tailored made for this purpose. Perhaps even using the FJ framework of Java 7 to parallelize the broadcast.
As I said, that would be completely pointless.Thank you!It all depends on what the goal is. If the sending thread should not be busy too long for sending messages to all the recipient, parallelizing the send of all messages is going to deliver a scalability improvement.And in case of sending 50k messages, I certainly is something worth considering.
Adding an entry into a ConcurrentLinkedQueue is in the nanosecond space.Try to do it concurrently and performance will drop singe the gc will kill scalability and performance.
Afaik you need to create at least 2 objects, the linked node in the queue and the message invocation.As the benchmark shows, cleaning millions of objects per second kills scalability.. And this is only use a true 8 core machine.. I guess when you go to the 32/64 core machines, performance drops even more.
I did some quick bench on my machine for 1 MILLION sends, it took between 150ms and 215ms (1 million queues (CLQ), adding the same, preallocated message to them)
For 50000 it took between 1 and 5 milliseconds (on my machine, a laptop, without cable plugged in)
Also, the point is quite moot since you cannot schedule them all to run at the same time _anyway_. Message sent != Message started to get processed
On Aug 6, 2011, at 9:37 PM, √iktor Ҡlang wrote:On Sat, Aug 6, 2011 at 12:54 PM, Ian Holsman <i...@holsman.net> wrote:
Thanks for the advice guys... I'll check out the FJ stuff in Java 7, and go back to latches.
I still don't understand why it's important for all actors to start processing the message at the same time, they need a thread to process the message anyway, and you don't have 50000 cores...
looking at the simulation i'm trying to solve, I don't need them to be exactly the same time. I'm more concerned that the first one in the loop always gets preference.
Imagine a game where you have thousands of people looking for a couple of treasures. and every 'tick' they are allowed to move.you don't want it so that the first one in the loop will always get the treasure as it gets there first all the time.
Depends on contention and choice of queue, 1000 threads writing to different queues (remember there was one million queues) is quite different from 1000 threads writing to 1 queue.
Afaik you need to create at least 2 objects, the linked node in the queue and the message invocation.As the benchmark shows, cleaning millions of objects per second kills scalability.. And this is only use a true 8 core machine.. I guess when you go to the 32/64 core machines, performance drops even more.
Yup, but then you could always switch to ArrayBlockingQueue so you won't need any allocations per send.
Depends on contention and choice of queue, 1000 threads writing to different queues (remember there was one million queues) is quite different from 1000 threads writing to 1 queue.
Even with 1 thread per queue without any form of contention, this is not going to scale since gc won't scale. That is the point.
Afaik you need to create at least 2 objects, the linked node in the queue and the message invocation.As the benchmark shows, cleaning millions of objects per second kills scalability.. And this is only use a true 8 core machine.. I guess when you go to the 32/64 core machines, performance drops even more.
Yup, but then you could always switch to ArrayBlockingQueue so you won't need any allocations per send.Not with the queue itself, but in case of Akka, you are still stuck with the MessageInvocation object.
On Sat, Aug 6, 2011 at 2:07 PM, Peter Veentjer <alarm...@gmail.com> wrote:
Depends on contention and choice of queue, 1000 threads writing to different queues (remember there was one million queues) is quite different from 1000 threads writing to 1 queue.
Even with 1 thread per queue without any form of contention, this is not going to scale since gc won't scale. That is the point.
There is nothing to GC until the message is processed.
looking at the simulation i'm trying to solve, I don't need them to be exactly the same time. I'm more concerned that the first one in the loop always gets preference.Imagine a game where you have thousands of people looking for a couple of treasures. and every 'tick' they are allowed to move.you don't want it so that the first one in the loop will always get the treasure as it gets there first all the time.