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

rustc_codegen_ssa: add time-passes output for each CGU compilation #81538

Conversation

tgnottingham
Copy link
Contributor

@tgnottingham tgnottingham commented Jan 29, 2021

Add time-passes event for each CGU compilation to LLVM IR. This is
useful to measure, as the event can cause a large increase in RSS.

Also, allow extra_verbose_generic_activity to accept multiple event
arguments.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 29, 2021
@tgnottingham
Copy link
Contributor Author

tgnottingham commented Jan 29, 2021

In conjunction with #81536, sample of -Z time-passes output for rustc_middle:

time:   0.000; rss:  1756MB ->  1756MB	find_cgu_reuse
time:   2.810; rss:  1756MB ->  1921MB	compile_codegen_unit(47luyf1dq9ttmk2y)
time:   3.587; rss:  1921MB ->  2204MB	compile_codegen_unit(5banyx1ghjvcxyne)
time:   4.355; rss:  2204MB ->  2482MB	compile_codegen_unit(2goq7lwe3l6np96t)
time:   3.161; rss:  2482MB ->  2712MB	compile_codegen_unit(qpagbtzbgw0u8oj)
time:   3.477; rss:  2712MB ->  2948MB	compile_codegen_unit(3mkkqle0ppntfa3i)
time:   1.266; rss:  2948MB ->  3057MB	compile_codegen_unit(47cjpiuhvj52boxv)
time:   0.680; rss:  3057MB ->  3114MB	compile_codegen_unit(4nihpc2q9xthln9l)
time:   1.846; rss:  3114MB ->  3261MB	compile_codegen_unit(z93ybhzpgfz689e)
time:   0.667; rss:  3261MB ->  3300MB  LLVM_module_optimize_function_passes(2goq7lwe3l6np96t)

See also #81536 (comment).

@rustbot label T-compiler

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 29, 2021
@bjorn3
Copy link
Member

bjorn3 commented Feb 1, 2021

It would be nice to also add it to

fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodegenResult {

@tgnottingham tgnottingham force-pushed the compile-codegen-unit-time-passes branch from 81feef5 to d5ee697 Compare February 5, 2021 01:05
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking rustdoc v0.0.0 (/checkout/src/librustdoc)
error[E0308]: mismatched types
  --> src/librustdoc/formats/renderer.rs:69:60
   |
69 |         .extra_verbose_generic_activity("create_renderer", T::descr())
   |                                                            ^^^^^^^^^^ expected slice, found `str`
   |
   = note: expected reference `&[_]`
              found reference `&'static str`
error[E0308]: mismatched types
   --> src/librustdoc/formats/renderer.rs:109:65
    |
    |
109 |     prof.extra_verbose_generic_activity("renderer_after_krate", T::descr())
    |                                                                 ^^^^^^^^^^ expected slice, found `str`
    |
    = note: expected reference `&[_]`
               found reference `&'static str`
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: could not compile `rustdoc`

@tgnottingham tgnottingham force-pushed the compile-codegen-unit-time-passes branch 2 times, most recently from b0813f8 to cf5e0e8 Compare February 5, 2021 01:18
@tgnottingham
Copy link
Contributor Author

tgnottingham commented Feb 5, 2021

Changed things a bit, but the end result is basically the same. Instead of adding a compile_codegen_unit event, I upgraded the codegen_module profile event to be included in -Z time-passes output, and added the same event for the cranelift backend.

Example output:

time:   0.013; rss:  178MB ->  201MB (  +23MB)  codegen_module(1wpvv7qlzclv3mr5, 502)

Add time-passes event for each CGU compilation to LLVM IR. This is
useful to measure, as the event can cause a large increase in RSS.

Also, allow `extra_verbose_generic_activity` to accept multiple event
arguments.
@tgnottingham tgnottingham force-pushed the compile-codegen-unit-time-passes branch from cf5e0e8 to 8529ae2 Compare February 5, 2021 22:14
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 23, 2021
@JohnCSimon
Copy link
Member

@rustbot label: -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 16, 2021
@crlf0710
Copy link
Member

crlf0710 commented Apr 2, 2021

@tgnottingham Ping from triage! What's the current status of this?

@tgnottingham
Copy link
Contributor Author

@crlf0710 Closing this, as I don't have the bandwidth right now and it's not of high importance.

@Sl1mb0 Sl1mb0 mentioned this pull request Sep 26, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants