| |
| Posted by max haughton in reply to Walter Bright | PermalinkReply |
|
max haughton
Posted in reply to Walter Bright
| On Tuesday, 9 May 2023 at 03:28:15 UTC, Walter Bright wrote:
> If the dmd builder builds dmd with the ENABLE_PROFILE=1, the resulting compiler will profile itself compiling a program. The results of the profile will be emitted to the file trace.log, which is described here:
>
> https://www.digitalmars.com/ctg/trace.html
>
> Yes, dmd inherited the profiler from the Digital Mars C++ profiler.
>
> It works by inserting code into the prolog and epilog of each function, calculating the time it takes the function to execute. It turns out that this takes a disastrously long time to run, so it is only useful for profiling with fairly short programs. Trying to profile dmd itself will likely have to wait until the sun becomes a red giant before it finishes.
>
> But anyhow, profiling compiles of smaller programs can work out nicely, and with the report in trace.log one can see where the problems are.
>
> Happy profiling!
perf (available on basically any Linux system) is a much better profiler.
Instrumentation-based profiling is almost always a worse option than sampling — even if the overhead was zero the data is much less useful.
-profile=gc is very useful, despite -profile being not particularly insightful
N.B. Compiling programs with base pointers always being emitted helps sampling profilers along quite a lot, DWARF implementations are not all made equal.
|