Performance of message-passing in the Actor model

2019-06-21 00:55发布

问题:

I've seen benchmarks of Actor model implementations done in terms of their actors. For example, Akka actors are very lightweight (600 bytes per actor) and millions of them can be created. However, I've never seen a benchmark done in terms of message-passing throughput.

For example, given some number of actors, how many messages can pass between them per second?

Does anyone have a link to such a performance benchmark (in terms of message-passing throughput)?

回答1:

Here is a benchmark implemented in

  • Akka 0.8.1 (Scala)
  • Scala Actors
  • Jetlang (Java)

Also see Azul Vega 1 + Scala actors and Azul Fast Bytecodes for Funny Languages and this paper.



回答2:

When I ran a performance test with this simple actor built around my implementation of the model it had a 444773.906 message per second throughput. Clearly it is a contrived test but it gives you a general idea of how it might perform in the wild.

private class TestActor : Actor<int, bool>
{
    protected override void ProcessMessage(AsyncReplyPackage<int, bool> package)
    {
        package.ReplyChannel.Send(package.Message > 2000000);
    }
}

static void Main(string[] args)
{
    var r = false;
    using (var ts = new TestActor())
    using (var rc = new AsyncChannel<bool>())
    {
        ts.PostWithAsyncReply(0, rc);
        r = rc.Receive();

        var count = 3000000;
        var sw = Stopwatch.StartNew();
        for (int i = 0; i < count; i++)
        {
            ts.PostWithAsyncReply(i, rc);
            r = rc.Receive();
        }
        Console.WriteLine(sw.Elapsed);
    }
    Console.WriteLine(r);
    Console.ReadLine();           
}

Size

I broke out the profiler and it looks like my implementation is 944 bytes. :(