rustc-perf icon indicating copy to clipboard operation
rustc-perf copied to clipboard

Use hardware performance counter data for the detailed/self-profile data view

Open wesleywiser opened this issue 3 years ago • 11 comments

Now that rustc supports using HPC data in -Zself-profile (rust-lang/rust#78781), it would be great to use this support on perf.rlo as well. Many of our smaller benchmarks don't run long enough for the std::time::Instant based profiling to work reliably which makes it hard to interpret the data when it doesn't really match the results reported on the summary page for a particular benchmark. By using the HPC data, hopefully this will improve the accuracy of detailed data view.

wesleywiser avatar Jun 15 '22 14:06 wesleywiser

instructions:u is also the default for the total counts, so it seems natural to compare it, instead of time - often there is a meaningful change in the total instructions:u, but it's lost in time noise in the query view.

Also, assuming it (still) works, I recommend -Z self-profile-counter=instructions-minus-irqs:u (instead of the plain instructions:u), to avoid weird jitter in otherwise-deterministic queries.

eddyb avatar Jun 17 '22 09:06 eddyb

Oh dear, it won't work yet, it's broken without adding features = ["nightly"] or updating the version of measureme that rustc uses (see https://github.com/rust-lang/rust/pull/78781#issuecomment-1165931887).

eddyb avatar Jun 24 '22 20:06 eddyb

Opened https://github.com/rust-lang/rust/pull/98471 to update measureme in rustc to resolve that.

wesleywiser avatar Jun 27 '22 15:06 wesleywiser

Opened rust-lang/rust#98471 to update measureme in rustc to resolve that.

Merged.

klensy avatar Jul 23 '22 19:07 klensy

I have tried to implement this, but I don't know how to actually read the HW counter data from the output of -Zself-profile. I'm using -Zself-profile -Zself-profile-counter=instructions:u, but the output file, when processed with summarize summarize --json, only contains information about time (I don't see any counter values).

Kobzol avatar Jul 07 '23 21:07 Kobzol

I think profiles either contain timestamps or instructions:u values, not both. Did you check that summarize summarize --json outputs values that make sense if the counters are time rather than instructions?

bjorn3 avatar Jul 07 '23 22:07 bjorn3

To be honest, I'm not really sure how to recognize that. It's true that when I turn on HW counters, the times seem to be diferent by orders of magnitude. So the counter values just get stored in the nanos attribute of time?

Kobzol avatar Jul 08 '23 06:07 Kobzol

The PR introducing the feature in rustc did mention this as somewhat backwards compatible for tools, until they adapt to the new counters. Maybe summarize is in that category.

lqd avatar Jul 08 '23 06:07 lqd

Yeah I saw that, but somehow I expected that this adoption has already happened in these 3 years 😅 Maybe not, I'll check how the tools work.

Kobzol avatar Jul 08 '23 06:07 Kobzol

Yeah it seems to just output time as nanoseconds.

Kobzol avatar Jul 08 '23 14:07 Kobzol

Reopening, because https://github.com/rust-lang/rustc-perf/pull/1647 had to be reverted because of some issue with measureme.

Kobzol avatar Aug 12 '23 13:08 Kobzol