diff --git a/collector/src/bin/rustc-fake.rs b/collector/src/bin/rustc-fake.rs index 3e079d1ef..98865c7b7 100644 --- a/collector/src/bin/rustc-fake.rs +++ b/collector/src/bin/rustc-fake.rs @@ -120,8 +120,9 @@ fn main() { if wrapper == "PerfStatSelfProfile" { cmd.arg(&format!( "-Zself-profile={}", - prof_out_dir.to_str().unwrap() + prof_out_dir.to_str().unwrap(), )); + cmd.arg("-Zself-profile-counter=instructions:u"); let _ = fs::remove_dir_all(&prof_out_dir); let _ = fs::create_dir_all(&prof_out_dir); } diff --git a/site/frontend/src/pages/detailed-query.ts b/site/frontend/src/pages/detailed-query.ts index be91d23b3..beaaec527 100644 --- a/site/frontend/src/pages/detailed-query.ts +++ b/site/frontend/src/pages/detailed-query.ts @@ -7,8 +7,8 @@ import { } from "../self-profile"; import {openTraceInPerfetto} from "../perfetto"; -function to_seconds(time) { - return time / 1000000000; +function normalize_value(value) { + return value; } function fmt_delta(to, delta, is_integral_delta) { @@ -305,14 +305,14 @@ function populate_data(data, state: Selector) { t.setAttribute("title", "% of cpu-time stat"); } } - td(row, to_seconds(cur.self_time).toFixed(3)); + td(row, normalize_value(cur.self_time)); if (delta) { td( row, fmt_delta( - to_seconds(cur.self_time), - to_seconds(delta.self_time), - false + normalize_value(cur.self_time), + normalize_value(delta.self_time), + true ), true ); @@ -329,16 +329,14 @@ function populate_data(data, state: Selector) { } else { td(row, "-", true); } - td(row, to_seconds(cur.incremental_load_time).toFixed(3)).classList.add( - "incr" - ); + td(row, normalize_value(cur.incremental_load_time)).classList.add("incr"); if (delta) { td( row, fmt_delta( - to_seconds(cur.incremental_load_time), - to_seconds(delta.incremental_load_time), - false + normalize_value(cur.incremental_load_time), + normalize_value(delta.incremental_load_time), + true ), true ).classList.add("incr"); diff --git a/site/frontend/templates/pages/detailed-query.html b/site/frontend/templates/pages/detailed-query.html index dbec34f59..e29215110 100644 --- a/site/frontend/templates/pages/detailed-query.html +++ b/site/frontend/templates/pages/detailed-query.html @@ -79,20 +79,21 @@

Artifact Size

-

'Time (%)' is the percentage of the cpu-clock time spent on this query (we do not use - wall-time as we want to account for parallelism).

+

'Instructions (%)' is the percentage of instructions executed on this query.

+

Note: self-profile measurements have been recently switched + from wall-time to HW counters (instruction count). If comparing with an older artifact, the timings might not be directly comparable.

Executions do not include cached executions.

- - - + + + - + diff --git a/site/src/api.rs b/site/src/api.rs index 79bdcbbae..207effe1a 100644 --- a/site/src/api.rs +++ b/site/src/api.rs @@ -471,19 +471,23 @@ pub mod self_profile { pub artifact_sizes: Option>, } + // Due to backwards compatibility, self profile event timing data is represented as durations, + // however since https://github.com/rust-lang/rustc-perf/pull/1647 it actually represents + // HW counter data (instruction counts). #[derive(Serialize, Deserialize, Clone, Debug)] pub struct QueryData { pub label: QueryLabel, - // Nanoseconds + // Instruction count pub time: u64, + // Instruction count pub self_time: u64, pub percent_total_time: f32, pub number_of_cache_misses: u32, pub number_of_cache_hits: u32, pub invocation_count: u32, - // Nanoseconds + // Instruction count pub blocked_time: u64, - // Nanoseconds + // Instruction count pub incremental_load_time: u64, } diff --git a/site/src/request_handlers/self_profile.rs b/site/src/request_handlers/self_profile.rs index 085adc9a3..aeba30caa 100644 --- a/site/src/request_handlers/self_profile.rs +++ b/site/src/request_handlers/self_profile.rs @@ -526,7 +526,7 @@ pub async fn handle_self_profile( .benchmark(selector::Selector::One(bench_name.to_string())) .profile(selector::Selector::One(profile.parse().unwrap())) .scenario(selector::Selector::One(scenario)) - .metric(selector::Selector::One(Metric::CpuClock)); + .metric(selector::Selector::One(Metric::InstructionsUser)); // Helper for finding an `ArtifactId` based on a commit sha let find_aid = |commit: &str| { @@ -541,9 +541,9 @@ pub async fn handle_self_profile( } let commits = Arc::new(commits); - let mut cpu_responses = ctxt.statistic_series(query, commits.clone()).await?; - assert_eq!(cpu_responses.len(), 1, "all selectors are exact"); - let mut cpu_response = cpu_responses.remove(0).series; + let mut instructions_responses = ctxt.statistic_series(query, commits.clone()).await?; + assert_eq!(instructions_responses.len(), 1, "all selectors are exact"); + let mut instructions_response = instructions_responses.remove(0).series; let mut self_profile = get_or_download_self_profile( ctxt, @@ -551,7 +551,7 @@ pub async fn handle_self_profile( bench_name, profile, scenario, - cpu_response.next().unwrap().1, + instructions_response.next().unwrap().1, ) .await?; let base_self_profile = match commits.get(1) { @@ -562,7 +562,7 @@ pub async fn handle_self_profile( bench_name, profile, scenario, - cpu_response.next().unwrap().1, + instructions_response.next().unwrap().1, ) .await?, ), diff --git a/site/src/self_profile.rs b/site/src/self_profile.rs index 1fee911e7..79e6fbe5b 100644 --- a/site/src/self_profile.rs +++ b/site/src/self_profile.rs @@ -318,7 +318,7 @@ pub(crate) async fn get_or_download_self_profile( } fn get_self_profile_data( - cpu_clock: Option, + total_instructions: Option, profile: &analyzeme::AnalysisResults, ) -> ServerResult { let total_self_time: Duration = profile.query_data.iter().map(|qd| qd.self_time).sum(); @@ -345,7 +345,7 @@ fn get_self_profile_data( time: profile.total_time.as_nanos() as u64, self_time: total_self_time.as_nanos() as u64, // TODO: check against wall-time from perf stats - percent_total_time: cpu_clock + percent_total_time: total_instructions .map(|w| ((total_self_time.as_secs_f64() / w) * 100.0) as f32) // sentinel "we couldn't compute this time" .unwrap_or(-100.0),
Query/FunctionTime (%)Time (s)Time deltaInstructions (%)InstructionsInstructions delta Executions Executions delta - Incremental loading (s) + Incremental loading instructions Incremental loading delta