The problem with the D GC

Sean Kelly sean at f4.ca
Mon Jan 8 09:09:46 PST 2007


kenny wrote:
> I also have experienced bad GC performance. I found it to be because of 
> the ~ operator on strings. The program is a daemon, and after it had 
> been running for a while, memory usage gets truly horrific, and 
> performance degrades very bad.
> 
> This was back on 0.140, so things may have changed since then...

Probably not.  Assuming this is a multithreaded app, you have to pay for 
two mutex locks for every concat operation.  So an expression like:

a = b ~ c ~ d;

would result in six locks of the mutex protecting the GC to perform 
allocations (I think anyway--I don't believe chained concats have 
special handling).  I think this would also result in two discarded 
temporary buffers for the GC to clean up later.  And since the Phobos GC 
scans all such blocks by default...

My patch will address the scanning issue, but it won't address the mutex 
issue--there's really no easy way to avoid that one.


Sean



More information about the Digitalmars-d mailing list