On Phobos GC hunt

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 7 13:13:31 PDT 2014


On 2014-10-07 17:57, Dmitry Olshansky wrote:
> I made a proposal to quantatively measure and tabulate all GC
> allocations in Phobos before coming up with solutions to "@nogc Phobos".
>
> After approving node from Andrei I've come up with a piece of automation
> to extract this data and post it on wiki.
>
> So here is the exhustive list of everything calling into GC in Phobos
> (-vgc compiler flag):
>
> http://wiki.dlang.org/Stuff_in_Phobos_That_Generates_Garbage
>
> Including source links, a wild guess at function's name and the
> compiler's warning message for potential GC call.
>
> As far as data goes this is about as good as we can get, the next phase
> is labeling this stuff with potential solution(s). Again doing all by
> hand is tedious and hardly useful.
>
> Instead we need to observe patterns and label it automatically until the
> non-trivial subset remains. So everybody, please take time and identify
> simple patterns and post back your ideas on solution(s).
>
> So far I see the most frequent cases:
> - `new SomeException` - switch to RC exceptions
> - AA access - ??? (use user-defined AA type as parameter?)
> - array concat - ???
> - closure - ???

I did some processing of the data and this is the results I got:

772 | 'new' causes GC allocation
515 | operator ~= may cause GC allocation
380 | operator ~ may cause GC allocation
113 | array literal may cause GC allocation
90  | setting 'length' may cause GC allocation
77  | indexing an associative array may cause GC allocation
34  | using closure causes GC allocation
16  | 'delete' requires GC
5   | associative array literal may cause GC allocation

Total 9

I didn't look at any source code to see what "new" is actually 
allocating, for example.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list