On Wednesday, 17 July 2024 at 18:29:03 UTC, Lance Bachmeier wrote:
> On Wednesday, 17 July 2024 at 16:53:36 UTC, Richard (Rikki) Andrew Cattermole wrote:
> Dmd simply does not have the optimizations to get anywhere close to a modern backend. It cannot come close to winning benchmarks.
This is the only point that matters in this discussion. DMD has a confusing switch that enables someone that doesn't use D to run a 90% suboptimal benchmark instead of a 100% suboptimal benchmark.
DMD compiles quickly and it usually produces code that runs fast enough. It should never be used for benchmarking. If -release is how you detect someone doing benchmarking, it should fail to compile when using that flag.
From what I see on: https://dlang.org/dmd-linux.html
"-O
Optimize generated code. For fastest executables, compile with the -O -release -inline -boundscheck=off switches together."
Indeed, that is probably good enough documentation that I understand what to do to generate something fast when the time comes. If there are more flags to tick on or off, we should probably add them. That said, I think it's worth thinking about these flags.
For example -- When I teach about 'build types/software life cycle' in my software engineering course, I often talk about 'debug' vs 'release' builds using those exact terms and with the understanding that debug build is 'slow with debugging symbols' and a release build is 'fast with no developer debugging checks (i.e. no asserts) on' that you give to the public.
I think the tricky thing is perhaps I have to unlearn from my 'C and C++ brain' some of the flags.
In my C and C++ brain: "-release" means "gcc -O2 -g0 ..."
In my C and C++ brain: "-debug" means "gcc -Wall -g3 ..."
In my D brain I really need to think about:
In D Debug Build means: "dmd -debug -g" or "dmd -g"
In D Release Candidate to the public: "dmd -O -release -inline -boundscheck=0ff ..."
Note: It seems dub documentation has a table otherwise explaining the different builds: https://dub.pm/dub-reference/build_settings/
Anyway -- while writing this post, one suggestion is to add a new section of documentation on the Command-line Reference titled "Common Build Flag Use Cases" which lists what flags are recommended for getting the most out of a debug or release build, or a build for benchmarking purposes.
I searched 'benchmark' on the wiki and did not immediately find this information: https://wiki.dlang.org/The_D_Programming_Language
Note: At some time I'll make a YouTube video talking about flags and builds, I just want to hold off if this thread comes to any conclusion :)