scalaz/scalaz — pull request #299 by plokhotnyuk (2013-03-06 16:33:51+00:00)
Title: Alternative implementation of actor code and tests for it

An alternative implementation of scalaz.concurrent.Actor to minimize latency and maximizing throughput of message passing.

Procs:
1. Increasing of message sending and handing throughput in ~3 times.
2. Decreasing of message pass latency from 30% (and up to 2 times when actor executed by FJ pool with parallelism = 2).
3. Decreasing number of store fences when handing messages (by using tail.lazySet and minimizing triggering of the suspended flag).

Cons:
1. Increasing memory footprint per actor in about 16 bytes (or 12 bytes for 32-bit JVM) due using two references for tail and head instead of one reference for mbox.

Dmitriy Vyukov's MPSC node-based queue was used as base: http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue

Rest of implementation details were borrowed from Martin's blog & presentations: http://mechanical-sympathy.blogspot.com/

I’d also like to say thank you to all the amazing people helped me by taking the trouble to reviewed code and tested on different environments: George Leontiev, Alexey Levan, Yaroslav Klymko, Maxim Fedorov, Alex Siman, Sergiy Onenko, Andrey Borisov.

The biggest thank you is for my wife and children, who had to deal with me hiding in a corner, coding & running benchmarks, when I should have
been helping out.