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

Document the usage of cargo-llvm-lines and -Ztimings. #905

Merged
merged 2 commits into from
Oct 4, 2020

Conversation

Julian-Wollersberger
Copy link
Contributor

@Julian-Wollersberger Julian-Wollersberger commented Oct 3, 2020

Here I document what I learned while making rust-lang/rust#76680:

  • How to use cargo-llvm-lines with x.py.
  • You can do CARGOFLAGS="-Ztimings" ./x.py whatever to get a nice timing chart.
  • Unrelated, I played around with tracy. Would need more work though to integrate with measureme.

This is blocked on dtolnay/cargo-llvm-lines#32.

@LeSeulArtichaut LeSeulArtichaut added the blocked This PR is blocked waiting for some other PR label Oct 3, 2020
src/profiling.md Outdated Show resolved Hide resolved
src/profiling.md Show resolved Hide resolved
src/profiling.md Outdated Show resolved Hide resolved
src/profiling.md Outdated
```

What I'm still not sure about is if inlining in MIR optimizations affect llvm-lines.
The output with `-Zmir-opt-level=0` and `-Zmir-opt-level=1` is the same,
Copy link
Member

Choose a reason for hiding this comment

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

Did you try -Zmir-opt-level=2? This might also be related to optimize=false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried it now and the difference is -0.2GB, but it doesn't seem to inline anything. This discussion says MIR inlining doesn't work yet.

src/profiling.md Outdated Show resolved Hide resolved
src/profiling.md Outdated Show resolved Hide resolved
src/profiling.md Outdated
Comment on lines 75 to 77
# A debug build takes _a fourth_ as long on my machine,
# but compiling more than stage0 rustc becomes unbearably slow.
optimize = false
Copy link
Member

Choose a reason for hiding this comment

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

Nice trick. Does this affect llvm-lines at all? Maybe it's a good thing if it does since it reflects how much LLVM IR is getting sent in the first place, not how small LLVM can make it with optimizations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently yes.
I did some more experimenting and the interactions between the different flags are more complicated than I thought. I'll rewrite the last paragraph.

Lines Copies Function name
----- ------ -------------
11802479 (100%) 52848 (100%) (TOTAL)
1663902 (14.1%) 400 (0.8%) rustc_query_system::query::plumbing::get_query_impl::{{closure}}
Copy link
Member

Choose a reason for hiding this comment

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

This seems like another good place to use dyn or just separate out most of the function. That's a lot of LLVM lines for only 400 instantiations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably. I haven't had much time yet to look into it, but it's tricky because the relevant traits aren't dyn safe.

@camelid
Copy link
Member

camelid commented Oct 3, 2020

This is blocked on dtolnay/cargo-llvm-lines#32.

That PR was merged!

@LeSeulArtichaut LeSeulArtichaut added waiting-on-review This PR is waiting for a reviewer to verify its content waiting-on-author This PR is waiting for additional action by the OP and removed blocked This PR is blocked waiting for some other PR waiting-on-review This PR is waiting for a reviewer to verify its content labels Oct 3, 2020
optimize, codegen-units and mir-opt do, but debug-assertions doesn't.
@Julian-Wollersberger
Copy link
Contributor Author

Julian-Wollersberger commented Oct 4, 2020

@jyn514 I've replaced the paragraph about mir-opt.

@rustbot modify labels +waiting-on-review -waiting-on-author
EDIT: Well, it was worth a shot.

@rustbot
Copy link
Collaborator

rustbot commented Oct 4, 2020

Error: The feature relabel is not enabled in this repository.
To enable it add its section in the triagebot.toml in the root of the repository.

Please let @rust-lang/release know if you're having trouble with this bot.

@JohnTitor JohnTitor added waiting-on-review This PR is waiting for a reviewer to verify its content and removed waiting-on-author This PR is waiting for additional action by the OP labels Oct 4, 2020
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

This looks great. Thank you so much for working on this!

@jyn514 jyn514 merged commit f787039 into rust-lang:master Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-review This PR is waiting for a reviewer to verify its content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants