dmd -run speed trends

Siarhei Siamashka siarhei.siamashka at gmail.com
Tue Dec 19 03:24:33 UTC 2023


On Tuesday, 19 December 2023 at 02:11:24 UTC, Walter Bright wrote:
> Thank you! But I'm a little confused. I'm not sure if the times 
> posted are runtime or compile time.

It's compile time + runtime + cache management overhead. Runtime 
is essentially zero and can be ignored here (see the source code 
of the program in the starter post of this thread).

Different caching strategies of the compiled binaries cause 
performance differences betwen `dmd -run`, `rdmd` and `dub`. The 
`dmd -run` case is a nearly pure compilation time with no cache 
management overhead. While `rdmd` and `dub` are somewhat slower.

> I'm interested in the runtime difference between writefln() and 
> printf().

The runtime differences between writefln() and printf() are 
neither tested nor discussed in this thread. People complain 
about the compilation time of writefln() and about the 
compilation time increase caused by importing various Phobos 
modules.

I myself don't mind moderately slower compilation time if it's a 
fair price for coding convenience. But I don't like when the 
compilation slowdown is caused by entirely stupid reasons. Such 
as static vs. dynamic linking of Phobos, missing PGO or a bad 
design of `rdmd`.

> This is because with the next version of Phobos, I'd like 
> performance issues of writefln() addressed.

Next Phobos version 2.107.0? Or a new Phobos design for D3?

BTW, I have https://github.com/competitive-dlang/speedy-stdio 
library, which runs circles around Phobos at runtime for the 
types of formatted output that it supports (and this 
special-cased fast-path code compiles as `@nogc`). But the 
library is slow to compile because of CTFE.


More information about the Digitalmars-d mailing list