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 more arguments to x perf #126853

Closed
wants to merge 5 commits into from
Closed

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Jun 23, 2024

Continues work from #126318, adds a CLI for running rustc-perf profiling commands.

This is probably most of what we can do so far, I'll add support for benchmarking once rustc-perf gets a terminal output for comparing benchmark results.

r? @onur-ozkan

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 23, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 23, 2024

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

src/bootstrap/src/core/build_steps/perf.rs Outdated Show resolved Hide resolved
Comment on lines +20 to +22
impl Default for PerfArgs {
fn default() -> Self {
Self { cmd: PerfCommand::Eprintln, opts: SharedOpts::default() }
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we run all the benchmarks by default with something like PerfCommand::All when the user doesn't specify a particular benchmark module (e.g., x perf)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify, these are individual profilers (eprintln, cachegrind, etc.), not benchmarks. I don't think that it makes sense to run all of them at once, it's like running cargo check/build/test at once, they just do very different things and serve different purposes. We could select some default, but I'm not sure if there even is a default profiler.

Once we actually add benchmarking in the future, I would propose x perf to just run benchmarks, but since we only have profilers now, I would opt into requiring users to select the profiler that they want to use.

Copy link
Member

Choose a reason for hiding this comment

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

IMO it makes more sense to run samply (perhaps even together with cachegrind) rather than running eprintln by default. Currently the eprintln default doesn't really provide a good overall report about the compiler.

Copy link
Contributor Author

@Kobzol Kobzol Jun 26, 2024

Choose a reason for hiding this comment

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

So, just to clarify, I would prefer to keep the current situation, where you cannot just do x perf, but you have to select some profiler. Because currently I don't think there is a good default - for both samply and cachegrind, you need to have an external tool installed, so that isn't IMO a good default.

This Default implementation should be basically unreachable!.

@onur-ozkan onur-ozkan 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 Jun 26, 2024
@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 26, 2024

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 26, 2024
@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 26, 2024

Btw, since this now actually does something, maybe we could let users know by adding an entry in the config tracker?

@rust-log-analyzer

This comment has been minimized.

Comment on lines +20 to +22
impl Default for PerfArgs {
fn default() -> Self {
Self { cmd: PerfCommand::Eprintln, opts: SharedOpts::default() }
Copy link
Member

Choose a reason for hiding this comment

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

IMO it makes more sense to run samply (perhaps even together with cachegrind) rather than running eprintln by default. Currently the eprintln default doesn't really provide a good overall report about the compiler.

Comment on lines +31 to +34
/// Run `profile_local samply`
/// This executes the compiler on the given benchmarks and profiles it with `samply`.
/// You need to install `samply`, e.g. using `cargo install --locked samply`.
Samply,
Copy link
Member

Choose a reason for hiding this comment

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

I just ran x perf samply and it turns out it needs root access (or I have to update /proc/sys/kernel/perf_event_paranoid). We probably need to extend this documentation here.

Copy link
Contributor Author

@Kobzol Kobzol Jun 26, 2024

Choose a reason for hiding this comment

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

Right, so this is a bit tricky. In general, many of the profilers require some custom configuration of the system, and also some postprocessing. This is documented in rustc-perf, and I'm not sure if it is a good idea to duplicate the documentation here.

The tool should let you know exactly what you should do w.r.t. perf_event_paranoid, so it is self-documenting in this sense, but if you prefer, we could add a mention of perf_event_paranoid (probably to rustc-perf?).

Furthermore, even if you run the profiler, it just generates a file on disk and unless you know what to do, it won't be very useful to you. So maybe we could create specific postprocessing steps in bootstrap, for example to open a web browser with the gathered profile after running samply. But even that is not that easy, because what if you run more than one benchmark? :)

Doing profiling and benchmarking does require some specific knowledge at the moment. We could make it easier for the user, but I'm not sure if that code belongs here or into rustc-perf, and how far should we go in this.

@onur-ozkan onur-ozkan added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 27, 2024
@Kobzol
Copy link
Contributor Author

Kobzol commented Jun 27, 2024

Closing in favor of #127002.

@Kobzol Kobzol closed this Jun 27, 2024
@Kobzol Kobzol deleted the bootstrap-perf-args branch June 27, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants