Skip to content

Commit a95bee1

Browse files
authored
Revert "Switch self profile to use HW counters instead of walltime" (#1700)
1 parent f174358 commit a95bee1

File tree

5 files changed

+33
-40
lines changed

5 files changed

+33
-40
lines changed

collector/src/bin/rustc-fake.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ fn main() {
9595
if wrapper == "PerfStatSelfProfile" {
9696
cmd.arg(&format!(
9797
"-Zself-profile={}",
98-
prof_out_dir.to_str().unwrap(),
98+
prof_out_dir.to_str().unwrap()
9999
));
100-
cmd.arg("-Zself-profile-counter=instructions:u");
101100
let _ = fs::remove_dir_all(&prof_out_dir);
102101
let _ = fs::create_dir_all(&prof_out_dir);
103102
}

site/frontend/src/pages/detailed-query.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {createUrlWithAppendedParams, getUrlParams} from "../utils/navigation";
22
import {postMsgpack} from "../utils/requests";
33
import {SELF_PROFILE_DATA_URL} from "../urls";
44

5-
function normalize_value(value) {
6-
return value;
5+
function to_seconds(time) {
6+
return time / 1000000000;
77
}
88

99
function fmt_delta(to, delta, is_integral_delta) {
@@ -267,14 +267,14 @@ function populate_data(data, state: Selector) {
267267
t.setAttribute("title", "% of cpu-time stat");
268268
}
269269
}
270-
td(row, normalize_value(cur.self_time));
270+
td(row, to_seconds(cur.self_time).toFixed(3));
271271
if (delta) {
272272
td(
273273
row,
274274
fmt_delta(
275-
normalize_value(cur.self_time),
276-
normalize_value(delta.self_time),
277-
true
275+
to_seconds(cur.self_time),
276+
to_seconds(delta.self_time),
277+
false
278278
),
279279
true
280280
);
@@ -291,14 +291,16 @@ function populate_data(data, state: Selector) {
291291
} else {
292292
td(row, "-", true);
293293
}
294-
td(row, normalize_value(cur.incremental_load_time)).classList.add("incr");
294+
td(row, to_seconds(cur.incremental_load_time).toFixed(3)).classList.add(
295+
"incr"
296+
);
295297
if (delta) {
296298
td(
297299
row,
298300
fmt_delta(
299-
normalize_value(cur.incremental_load_time),
300-
normalize_value(delta.incremental_load_time),
301-
true
301+
to_seconds(cur.incremental_load_time),
302+
to_seconds(delta.incremental_load_time),
303+
false
302304
),
303305
true
304306
).classList.add("incr");

site/frontend/templates/pages/detailed-query.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,20 @@ <h4>Artifact Size</h4>
7979
<tbody id="artifact-body">
8080
</tbody>
8181
</table>
82-
<p>'Instructions (%)' is the percentage of instructions executed on this query.</p>
83-
<p><b>Note: self-profile measurements have been <a href="https://github.com/rust-lang/rustc-perf/pull/1647">recently switched</a>
84-
from wall-time to HW counters (instruction count). If comparing with an older artifact, the timings might not be directly comparable.</b></p>
82+
<p>'Time (%)' is the percentage of the cpu-clock time spent on this query (we do not use
83+
wall-time as we want to account for parallelism).</p>
8584
<p>Executions do not include cached executions.</p>
8685
<table>
8786
<thead>
8887
<tr id="table-header">
8988
<th data-sort-idx="1" data-default-sort-dir="1">Query/Function</th>
90-
<th data-sort-idx="10" data-default-sort-dir="-1">Instructions (%)</th>
91-
<th data-sort-idx="2" data-default-sort-dir="-1">Instructions</th>
92-
<th data-sort-idx="11" data-default-sort-dir="-1" class="delta">Instructions delta</th>
89+
<th data-sort-idx="10" data-default-sort-dir="-1">Time (%)</th>
90+
<th data-sort-idx="2" data-default-sort-dir="-1">Time (s)</th>
91+
<th data-sort-idx="11" data-default-sort-dir="-1" class="delta">Time delta</th>
9392
<th data-sort-idx="5" data-default-sort-dir="-1">Executions</th>
9493
<th data-sort-idx="12" data-default-sort-dir="-1" class="delta">Executions delta</th>
95-
<th class="incr" data-sort-idx="7" data-default-sort-dir="-1" title="Incremental loading instructions">
96-
Incremental loading instructions</th>
94+
<th class="incr" data-sort-idx="7" data-default-sort-dir="-1" title="Incremental loading time">
95+
Incremental loading (s)</th>
9796
<th class="incr delta" data-sort-idx="13" data-default-sort-dir="-1">Incremental loading delta</th>
9897
</tr>
9998
</thead>

site/src/api.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,21 +345,18 @@ pub mod self_profile {
345345
pub artifact_sizes: Option<Vec<ArtifactSize>>,
346346
}
347347

348-
// Due to backwards compatibility, self profile event timing data is represented as durations,
349-
// however since https://github.com/rust-lang/rustc-perf/pull/1647 it actually represents
350-
// HW counter data (instruction counts).
351348
#[derive(Serialize, Deserialize, Clone, Debug)]
352349
pub struct QueryData {
353350
pub label: QueryLabel,
354-
// Instruction count
351+
// Nanoseconds
355352
pub self_time: u64,
356353
pub percent_total_time: f32,
357354
pub number_of_cache_misses: u32,
358355
pub number_of_cache_hits: u32,
359356
pub invocation_count: u32,
360-
// Instruction count
357+
// Nanoseconds
361358
pub blocked_time: u64,
362-
// Instruction count
359+
// Nanoseconds
363360
pub incremental_load_time: u64,
364361
}
365362

site/src/request_handlers/self_profile.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub async fn handle_self_profile_processed_download(
155155
}
156156

157157
fn get_self_profile_data(
158-
total_instructions: Option<f64>,
158+
cpu_clock: Option<f64>,
159159
profile: &analyzeme::AnalysisResults,
160160
) -> ServerResult<self_profile::SelfProfile> {
161161
let total_time: Duration = profile.query_data.iter().map(|qd| qd.self_time).sum();
@@ -180,7 +180,7 @@ fn get_self_profile_data(
180180
label: "Totals".into(),
181181
self_time: total_time.as_nanos() as u64,
182182
// TODO: check against wall-time from perf stats
183-
percent_total_time: total_instructions
183+
percent_total_time: cpu_clock
184184
.map(|w| ((total_time.as_secs_f64() / w) * 100.0) as f32)
185185
// sentinel "we couldn't compute this time"
186186
.unwrap_or(-100.0),
@@ -587,7 +587,7 @@ pub async fn handle_self_profile(
587587
.benchmark(selector::Selector::One(bench_name.to_string()))
588588
.profile(selector::Selector::One(profile.parse().unwrap()))
589589
.scenario(selector::Selector::One(scenario))
590-
.metric(selector::Selector::One(Metric::InstructionsUser));
590+
.metric(selector::Selector::One(Metric::CpuClock));
591591

592592
// Helper for finding an `ArtifactId` based on a commit sha
593593
let find_aid = |commit: &str| {
@@ -602,9 +602,9 @@ pub async fn handle_self_profile(
602602
}
603603
let commits = Arc::new(commits);
604604

605-
let mut instructions_responses = ctxt.statistic_series(query, commits.clone()).await?;
606-
assert_eq!(instructions_responses.len(), 1, "all selectors are exact");
607-
let mut instructions_response = instructions_responses.remove(0).series;
605+
let mut cpu_responses = ctxt.statistic_series(query, commits.clone()).await?;
606+
assert_eq!(cpu_responses.len(), 1, "all selectors are exact");
607+
let mut cpu_response = cpu_responses.remove(0).series;
608608

609609
let mut self_profile_data = Vec::new();
610610
let conn = ctxt.conn().await;
@@ -623,16 +623,12 @@ pub async fn handle_self_profile(
623623
}
624624
}
625625
let profiling_data = self_profile_data.remove(0).perform_analysis();
626-
let mut profile =
627-
get_self_profile_data(instructions_response.next().unwrap().1, &profiling_data)
628-
.map_err(|e| format!("{}: {}", body.commit, e))?;
626+
let mut profile = get_self_profile_data(cpu_response.next().unwrap().1, &profiling_data)
627+
.map_err(|e| format!("{}: {}", body.commit, e))?;
629628
let (base_profile, base_raw_data) = if body.base_commit.is_some() {
630629
let base_profiling_data = self_profile_data.remove(0).perform_analysis();
631-
let profile = get_self_profile_data(
632-
instructions_response.next().unwrap().1,
633-
&base_profiling_data,
634-
)
635-
.map_err(|e| format!("{}: {}", body.base_commit.as_ref().unwrap(), e))?;
630+
let profile = get_self_profile_data(cpu_response.next().unwrap().1, &base_profiling_data)
631+
.map_err(|e| format!("{}: {}", body.base_commit.as_ref().unwrap(), e))?;
636632
(Some(profile), Some(base_profiling_data))
637633
} else {
638634
(None, None)

0 commit comments

Comments
 (0)