[haiku-development] Re: Disruptor Pattern

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 14 Mar 2012 16:52:21 +0100

Hi,

Am 13.03.2012 10:03, schrieb x-otic@xxxxxxx:
I wanted to share a find I stumbled upon recently.
It's the "disruptor pattern" [1] which was open-sourced last year
titled "High performance alternative to bounded queues for
exchanging data between concurrent threads" [2].
Although my knowledge on concurrency is very limited,
the descriptions of this pattern sound to me like a break-through for
heavy multi-core, multi-threaded applications.
Basically, the inventors came up with an idea to avoid thread-locking mostly.

Isn't that of some value to Haiku?
(Don't bash me if it's not..)

I've read the paper and it is definitely very interesting. Following your link to the C++ port, there seems to be a newer version that depends on C++Ox instead of boost and boost-atomic. The code size is rather small, since it "only" implements a data structure and provides some interfaces. So it should be rather little effort to port it to Haiku's atomic_* API and make it work on GCC2 as well, but I haven't looked closer.

I don't know if this can replace some crucial parts of the Application Kit implementation, like the inner locks around message queues and such stuff, but it would be definitely useful in the Support Kit for applications to use, if nothing else. It could be the basis for a "thread pool" like API, if I understand things correctly.

In any case, this structure is about high-throughput, CPU intensive processing, where you want to avoid the latency overhead of locking when scheduling the work packets between the involved threads. It is not so much about general purpose message passing between threads, like a BButton sending an event and such. It is also not suitable for cross-application message passing, like BViews sending commands to the app_server, since it depends on memory barriers that, AFAICT, only work within a single address space.

Nice read in any case, thanks!

Best regards,
-Stephan

Other related posts: