Linus with some good observations on garbage collection

Timon Gehr timon.gehr at gmx.ch
Sun Apr 24 17:10:14 PDT 2011


Andrei Alexandrescu wrote:
> I am sorry, you simply have no case - each and every argument you put
> forth has no strength or is just wrong. We could spend time on debating
> each, but I suspect that would do little toward convincing you of what
> is after all a simple fact, but one with many subtle facets. It might
> not a good use of our time to further engage in a diatribe on this. The
> delete keyword will go, as will class-specific new and delete.
>
>
> Andrei

Ok, lets stop. Custom allocators and delete should probably be removed from D:

Some of my facts:
* freelist is faster if most allocation and deallocation concentrates on only one
class. (see attachment) I think this is also the reason it increases DMDs speed.
Token and Scope are quite obvious bottlenecks..
* such bottlenecks will most of the time only be detected when development is
almost finished. (Almost never for library code, so I don't get why STL uses
custom allocators at all.)
* premature optimization is evil (see STL custom allocators)
* late optimization: it is easy if there are custom allocators. In C++ it is even
trivial. Nice design. Still no clue why STL is abusing it.
* that form of custom allocators does not play nicely with Ds Garbage collector
though, because it changes the semantics of 'new', ergo builtin custom allocators
should probably indeed be removed from D.
* this makes this form of optimization painful in D without custom allocators.
This is what I was instinctively scared about. Fact is: it is also painful with
them, because you don't get the 'delete's for free as in C++. I was somewhat
inconsiderate on this.
* it is possible that hinting the GC is only about twice as bad (again, see
attachment).


And some notes:
* the fact that you think all my points were worthless or wrong implies that you
either did not read all of them or have not considered them yourself when making
your decision. I think that is scary.
* There are many ways in which I am always right. The most dominant being that any
sufficiently smart guy with a PhD in rocket science would totally agree with all
my statements. No pun/offense intended.
* this discussion would have been a waste of your time, had it not been public.


Thanks for discussing. It was helpful.


Timon

PS: The current GC dies without hints on my benchmark, so it is indeed a nice idea
to keep hints:
version=GC:       1m45s
version=GC_hints: ~6.8s
version=freelist: ~3.7s
version=c_heap:   ~4.5s
begin 644 benchmark.d
M+RH at 0F5N8VAM87)K($=#('9S($=#("8@:&EN=',@=G, at 9G)E96QI<W0@=G,@
M0R!(96%P"B`J($UY(&UE87-U<F5M96YT<R!O;B!);G1E;"!#;W)E($1U;R`R
M>#(N-"!':%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7-T.PH)"0D)9G)E96QI
M<W0]8V%S="AF;V\I<#L*"0D)"69R965L:7-T+FYE>'0];VQD9FP["@D)"7T*
M"0E]"@E]"@EV97)S:6]N*&-?:&5A<"E["@D);F5W*'-I>F5?="!S*7MR971U
M<FX@;6%L;&]C*',I.WT*"0ED96QE=&4H=F]I9"`J<"E[:68H<"D at 9G)E92AP
M*3M]"@E]"GT["@IF;V];,3`P,#`P72!A.PH*=F]I9"!M86EN*"E["@ES<F%N
M9"@Q,#`I.PH):6YT('1O<#L*"6EN="!D:7([+R\P.B!E>'!E8W1E9"!G<F]W
M:6YG+"`Q.B!E>'!E8W1E9"!S:')I;FMI;F<*"69O<F5A8V at H=#LP+BXQ,#`P
M,#`P,"E["@D):68H(71O<"E["@D)"6%;=&]P*RM=/6YE=R!F;V\["@D)"61I
M<CTP.PH)"7UE;'-E(&EF*'1O<#T],3`P,#`P*7L*"0D)=&]P+2T["@D)"79E
M<G-I;VXH8V%L;&1E;"D at 9&5L971E(&%;=&]P73L*"0D)9&ER/3$["@D)?65L
M<V4@:68H9&ER7B$H<F%N9"@I)3,I*7LO+VEF*"%D:7(F)B$H<F%N9"@I)3,I
M?'QD:7(F)G)A;F0H*24S*7L*"0D)=&]P+2T["@D)"79E<G-I;VXH8V%L;&1E
M;"D at 9&5L971E(&%;=&]P73L*"0E]96QS92!A6W1O<"LK73UN97<@9F]O.PH)
M"6EF*"%R86YD*"DE,3`P*2!F;W(H:6YT(&D],#MI/#$P,#MI*RLI('-W87`H
985LP72QA6W)A;F0H*25T;W!=*3L*"7T*?0``
`
end


More information about the Digitalmars-d mailing list