Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --ftime-trace functionality. #3624

Merged
merged 5 commits into from
Dec 28, 2020

Conversation

JohanEngelen
Copy link
Member

This uses LLVM's TimeProfiler functionality, such that LLVM's work is traced in the same profile (optimization and machine code gen).
Functionality is meant to be identical to Clang and LLD's --ftime-trace.

@kinke
Copy link
Member

kinke commented Nov 29, 2020

Oh wow, that's probably a valuable addition...

@JohanEngelen
Copy link
Member Author

@kinke What do you think of the way I added it? I tried to touch DMD frontend code as minimal as possible.

Yeah, it's quite insightful to see the traces. I'm using it to try and speed up compile times at Weka (e.g. now you can see clearly that importing a particular module costs 5 seconds).

If you want to try it, I recommend using Tracy for viewing the profile. Get the profile from LDC, convert it using Tracy's import-chrome tool, and view it in Tracy's profile GUI. It's a much much much faster UI than chrome::tracing.

This uses LLVM's TimeProfiler functionality, such that LLVM's work is traced in the same profile (optimization and machine code gen).
Functionality is meant to be identical to Clang and LLD's --ftime-trace.
this.semavisitor = semavisitor;
}

alias visit = Visitor.visit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just use alias visit = SemaVisitor.visit? Or do you want to be notified whenever a new override is added to SemaVisitor and decide whether to just forward in the 90+% of cases or to add a new trace scope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can't work because I have to forward the visit call to semavisitor.visit instead of this.SemaVisitor.visit. The semantic analysis visitors are final which is probably good for performance, but requires this nuisance of manually overriding all overrides (and hence the static if check to fail when something gets added....)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch yeah I remember some PR which attempted to make them non-final and I opposed against it. ;)

@JohanEngelen
Copy link
Member Author

Added a testcase before merging.

@JohanEngelen
Copy link
Member Author

Merging. The Azure failures are due to LLVM package not being available for Ubuntu 16 (but they are for 20).

@JohanEngelen JohanEngelen merged commit 29245c8 into ldc-developers:master Dec 28, 2020
@JohanEngelen JohanEngelen deleted the ftime-trace branch December 28, 2020 16:05
JohanEngelen added a commit to weka/ldc that referenced this pull request Dec 28, 2020
This uses LLVM's TimeProfiler functionality, such that LLVM's work is traced in the same profile (optimization and machine code gen).
Functionality is meant to be identical to Clang and LLD's --ftime-trace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants