[std.concurrency] prioritySend is 1000 times slower than send?

Sean Kelly sean at invisibleduck.org
Thu Sep 30 11:45:48 PDT 2010


Sean Kelly Wrote:

> osa Wrote:
> 
> > I started using std.concurrency in some projects and overall it feels 
> > like a solid (albeit minimalistic) design. However, current 
> > implementation has some issues. For example, I've noticed that using 
> > prioritySend slows everything considerably.
> 
> Thanks for this.  I can tell you that prioritySend performs an extra allocation to account for a design requirement (if a priority message isn't received it's thrown as PriorityMessage!(T), and this exception is generated when the send occurs, since static type info isn't available at the receive side when it's needed for this).  I had originally thought that the difference was just more garbage collections, but calling GC.disable only increases the number of priority messages sent by about 1000.  I'll have to look at the code to see if I can figure out what's going on.

Okay, I've fixed one issue with priority messages that, aside from broken behavior, has increased performance somewhat.  Here are the timings:

Benchmark: 5944400 iterations in 5 seconds (1.18888e+06/second) -- built without -version=priority
Benchmark: 4900 iterations in 5.119 seconds (957.218/second) -- build with -version=priority before fix
Benchmark: 39700 iterations in 5.001 seconds (7938.41/second) -- built with version=priority after fix

The remaining issue has to do with the fact that the exception is constructed when the send is issued and when this exception is constructed a stack trace is generated as well.  I'll have to modify Throwable so that derived classes can specify that no trace be generated.  That or eliminate constructing the exception at the send site and change how that exception is represented.


More information about the Digitalmars-d mailing list