I'm trying to tweak the GC when compiling with dub, starting with something easy like profile:1.

$ grep dflags dub.json
    "dflags": [ "-lowmem", "--DRT-gcopt=profile:1" ],
$ dub test

Doesn't work, doesn't give any extra output. Entering bogus flags like --DRT-gcopt=banana:1 doesn't evoke any error message either, making me doubt it's being passed on at all.

$ dmd -oftest -lowmem --DRT-gcopt=profile:1 source/**/*.d
        Number of collections:  13
        Total GC prep time:  7 milliseconds
        Total mark time:  2110 milliseconds
        Total sweep time:  270 milliseconds
        Total page recovery time:  204 milliseconds
        Max Pause Time:  472 milliseconds
        Grand total GC time:  2592 milliseconds
GC summary: 1099 MB,   13 GC 2592 ms, Pauses 2117 ms <  472 ms

Manual dmd invocation does work, so it's not like dmd is ignoring --DRT-gcopt.

$ dub test --DRT-gcopt=profile:1
[...]
        Number of collections:  10
        Total GC prep time:  0 milliseconds
        Total mark time:  4 milliseconds
        Total sweep time:  7 milliseconds
        Total page recovery time:  4 milliseconds
        Max Pause Time:  0 milliseconds
        Grand total GC time:  15 milliseconds
GC summary:   12 MB,   10 GC   15 ms, Pauses    4 ms <    0 ms

The totals should be in the ballpark of 1Gb+ (as above), not 12Mb. Is it only profiling dub itself? (Incidentally this is roughly what dmd reports if called without -lowmem.)

$ export DRT_GCOPT=profile:1
$ dub test

Doesn't work either, I can't actually get the env var to affect dmd at all, even when manually running it.

What is the correct way?

Reply via email to