dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Merge and use time trace sources into dmd

Open maxhaton opened this issue 2 years ago • 16 comments

For anyone who doesn't know this is the time-trace facility from LDC. It's effectively a one-stop-shop for profiling compile times, simultaneously providing a simple high level view (with an appropriate profile viewer) of compilation (at the level of files and imports of those files)

The timetrace.d file is in common so it can eventually be used in the backend (code generation, especially as a symptom of overzealous use of templates, is not free and object emission can be very not free since the dmd implementation of (say) ELF doesn't scale to large N very well). At the moment however it's only used by the frontend.

@JohanEngelen I had to remove some phobos usage, hopefully i didn't alter anything Also @thewilsonator @kinke to make you aware of an upcoming change if this gets merged.

maxhaton avatar Apr 08 '22 02:04 maxhaton

Thanks for your pull request, @maxhaton!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#13965"

dlang-bot avatar Apr 08 '22 02:04 dlang-bot

This isn't completely ready yet but I wanna run it through the CI pipelines

maxhaton avatar Apr 08 '22 02:04 maxhaton

dmd.globals thing is going to be annoying. that being said within a reasonable definition of common I guess the globals should be common to them both?

maxhaton avatar Apr 08 '22 02:04 maxhaton

As a user of --ftime-trace in LDC, I like having the same in dmd, especially with the same command line interface / output format.

@kinke when this gets merged, can you use the same source as DMD or will LDC keep its own time trace implementation? In the latter case, the version (LDC) branches in this PR are unnecessary.

This isn't completely ready yet but I wanna run it through the CI pipelines

I've marked it as draft, please notify when it's ready for review.

dkorpel avatar Apr 08 '22 08:04 dkorpel

@JohanEngelen I had to remove some phobos usage, hopefully i didn't alter anything.

Add a comment to the copied function(s) with a link to phobos. Such that bugfixes in Phobos may at some point also land in the copied functions. (fwiw: I am against the DMD design choice to not use the Dlang standard library).

JohanEngelen avatar Apr 08 '22 10:04 JohanEngelen

@JohanEngelen I had to remove some phobos usage, hopefully i didn't alter anything.

Add a comment to the copied function(s) with a link to phobos. Such that bugfixes in Phobos may at some point also land in the copied functions. (fwiw: I am against the DMD design choice to not use the Dlang standard library).

It was only string manipulation, just pointed it out in case someone is parsing it somewhere (for example).

maxhaton avatar Apr 08 '22 12:04 maxhaton

@maxhaton Any progress on this?

RazvanN7 avatar Apr 25 '22 13:04 RazvanN7

@maxhaton ping

dkorpel avatar Jun 22 '22 15:06 dkorpel

Does this work include tracing of memory usage?

nordlow avatar Nov 14 '22 18:11 nordlow

Does this work include tracing of memory usage?

Yes. Use LDC ;-)

JohanEngelen avatar Nov 14 '22 19:11 JohanEngelen

Does this solution include template instance types into the trace?

nordlow avatar Nov 14 '22 19:11 nordlow

Does this solution include template instance types into the trace?

Are you saying memory tracing is not included in this DMD PR?

nordlow avatar Nov 14 '22 19:11 nordlow

What I am saying is: just use LDC. It has this functionality for a while now, and you can see for yourself what it does and does not do.

JohanEngelen avatar Nov 14 '22 21:11 JohanEngelen

I don't understand how this works. How are probes performed? By stopping the process? Because I see no injection of probes anywhere in the existing dmd source code. Ping, @maxhaton.

nordlow avatar Nov 15 '22 01:11 nordlow

Could you please provide a link to the documentation on what this switch does?

WalterBright avatar Sep 28 '23 02:09 WalterBright

There's no written documentation yet, but I created a video tutorial: https://forum.dlang.org/post/[email protected]

dkorpel avatar Sep 28 '23 08:09 dkorpel

Rebooted in https://github.com/dlang/dmd/pull/16363

dkorpel avatar Apr 07 '24 19:04 dkorpel

Nice. I don't really have time for much DMD stuff these days but I'll try and help you get that reviewed and merged @dkorpel

On Sun, 7 Apr 2024, 20:23 Dennis, @.***> wrote:

Rebooted in #16363 https://github.com/dlang/dmd/pull/16363

— Reply to this email directly, view it on GitHub https://github.com/dlang/dmd/pull/13965#issuecomment-2041576510, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLI75CSOYFBKSUJC45NQLDY4GMLFAVCNFSM5S3EZ4DKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBUGE2TONRVGEYA . You are receiving this because you were mentioned.Message ID: @.***>

maxhaton avatar Apr 07 '24 20:04 maxhaton