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 "Rust codegen" as a new compilation section #1864

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Mar 16, 2024

Inspired by discussions about my recent blog post, I thought that it would be nice if we split the "Backend" section into the actual backend (e.g. LLVM) and the Rust part that monomorphizes stuff and generates LLVM IR from MIR. This PR does that:

image

Based on #1858.

frontend_end = event.payload.timestamp().map(|t| t.end());
if event.label == "collect_and_partition_mono_items" {
// We mark this query as "Rust codegen", where monomorphization and MIR-to-backend
// conversion happens.
Copy link
Member

Choose a reason for hiding this comment

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

collect_and_partition_mono_items happens before the translation from MIR to llvm ir. It is the step which determines which instances to actually codegen and into which codegen unit. I believe it also implicitly loads the MIR for dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aah, you're right, thanks. The MIR-to-IR translation happens in codegen_module, right? That explains the staircase shape:
image

Hmm, then this becomes quite tricky, as the MIR-to-IR computation is overlaid with LLVM, and we can no longer render it as a separate part.

I still think that the mono collector is a reasonably self-contained part and it could be useful to visualize it (with a more accurate description, of course). What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

The MIR-to-IR translation happens in codegen_module, right?

Yes

Hmm, then this becomes quite tricky, as the MIR-to-IR computation is overlaid with LLVM, and we can no longer render it as a separate part.

If you make the graph represent cpu-clock (time spent on each individual thread added together) rather than task-clock or wall-time you can add all codegen_module queries together to form "Rust codegen" time and all codegen_module_optimize queries to form "backend" time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cpu-clock is not supported by self-profile, and also if we added time of multiple threads together, it would no longer make sense to show this in the same chart as a fraction of the whole compilation time (it could be another chart, but that's probably overkill).

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.

None yet

2 participants