Why does std.concurrency.Mailbox use lists ?
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 8 17:36:28 PDT 2014
On 9/8/14, 10:06 AM, badlink wrote:
> Hello,
> I'm creating a real-time 3D app using std.concurrency for exchanging
> messages between the renderer and a few mesher threads.
> The app runs fine, but once in a while I get a consistent FPS drop.
> Already aware that the cause is the GC (a call to GC.disable eliminates
> the slowdowns) I timed all functions and found that spawn() sometimes
> requires more than 50 ms to returns.
> I did a quick search through Phobos and found out that the Mailbox
> implementation in std.concurency uses a private List struct where every
> call to .put() needs to allocate a new node :(
>
> Why is that ?
> I would have used for example a ring buffer which can do all the things
> the Mailbox needs and faster in every way. The growing time can be
> compensated by a right call to setMaxMailboxSize() and any random
> removal can be a swap of the last element with the one being removed.
>
> If I haven't overlooked something, I'd like to fill a performance bug on
> Bugzilla.
Yah, that does look like a perf bug. Please bugzillize and assign
provisionally to Sean. -- Andrei
More information about the Digitalmars-d
mailing list