Challenge: write a reference counted slice that works as much as possible like a built-in slice
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Nov 12 23:06:28 UTC 2021
On Friday, 12 November 2021 at 22:10:22 UTC, H. S. Teoh wrote:
> This is why I also say, why are people so hung up about the GC?
> If your inner loops have performance problems with the GC,
> then rewrite it as @nogc, use malloc/free/whatever it takes to
> make it faster.
If you have a large scannable heap then scanning will pollute the
shared memory caches. Unless your scanning code use load/save
instructions that bypass the caches. So in essence GC collection
affects the whole system, also @nogc code. Another downside of
imprecise scanning is that you need to zero out memory in order
to make sure memory gets freed.
Now, if you tied a fully precise GC to a smaller unit, like a
computation, then you could get better performance than other
schemes since you often could just drop the whole heap without
scanning when the computation is complete.
But the chosen path for D does not allow this, as of today, which
does give people reason to wonder about the future direction for
language evolution.
More information about the Digitalmars-d
mailing list