GDC - program runs in one thread, DMD - in 4 threads, why?

Adam D Ruppe destructionator at gmail.com
Fri Sep 10 11:32:02 UTC 2021


On Friday, 10 September 2021 at 09:27:49 UTC, eugene wrote:
> What are these extra threads for?
> GC?
>
> So I think it is **very aggressive usage** of DList that causes 
> this.

Yeah, in newer versions, when the garbage collector does its 
first collect, it spawns some helper threads to speed up its mark 
process. When the GC is not actively marking, those extra threads 
are 100% idle, so they don't affect the rest of your program.

> Can this (really unwanted) behavior be disabled in DMD?
> I do not want to have multiple threads,

here's the page on it
https://dlang.org/spec/garbage.html#gc_config

You either pass as an argument *to your application*

--DRT-gcopt=parallel:0

or to make it permanent, in your source file with the main() 
function, add this:

extern(C) __gshared string[] rt_options = [ "gcopt=parallel:0" ];


and it will stop doing that.


More information about the Digitalmars-d-learn mailing list