On Monday, 8 September 2014 at 17:06:34 UTC, 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.


AFAICS, the documentation doesn't write about any ordering guarantees of messages, but I can imagine that there are implicit expectations. In particular prioritySend() could break, if the implementation isn't done carefully.

Reply via email to