Skip to content

Commit 07fa96c

Browse files
committed
Document the switch to HW counters
1 parent 0b72313 commit 07fa96c

File tree

3 files changed

+45
-35
lines changed

3 files changed

+45
-35
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ <h4>Artifact Size</h4>
8080
</tbody>
8181
</table>
8282
<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>
8385
<p>Executions do not include cached executions.</p>
8486
<table>
8587
<thead>

site/src/api.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,22 @@ pub mod self_profile {
333333
pub artifact_sizes: Option<Vec<ArtifactSize>>,
334334
}
335335

336+
// Due to backwards compatibility, self profile event timing data is represented as durations,
337+
// however since https://github.com/rust-lang/rustc-perf/pull/1647 it actually represents
338+
// HW counter data (instruction counts).
336339
#[derive(Serialize, Deserialize, Clone, Debug)]
337340
pub struct QueryData {
341+
// Instruction count
342+
pub self_instructions: u64,
338343
pub label: QueryLabel,
339-
// Nanoseconds
340-
pub self_time: u64,
341344
pub percent_total_time: f32,
342345
pub number_of_cache_misses: u32,
343346
pub number_of_cache_hits: u32,
344347
pub invocation_count: u32,
345-
// Nanoseconds
346-
pub blocked_time: u64,
347-
// Nanoseconds
348-
pub incremental_load_time: u64,
348+
// Instruction count
349+
pub blocked_instructions: u64,
350+
// Instruction count
351+
pub incremental_load_instructions: u64,
349352
}
350353

351354
#[derive(Serialize, Deserialize, Clone, Debug)]

site/src/request_handlers/self_profile.rs

Lines changed: 34 additions & 29 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-
cpu_clock: Option<f64>,
158+
total_instructions: 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();
@@ -165,22 +165,22 @@ fn get_self_profile_data(
165165
.iter()
166166
.map(|qd| self_profile::QueryData {
167167
label: qd.label.as_str().into(),
168-
self_time: qd.self_time.as_nanos() as u64,
168+
self_instructions: qd.self_time.as_nanos() as u64,
169169
percent_total_time: ((qd.self_time.as_secs_f64() / total_time.as_secs_f64()) * 100.0)
170170
as f32,
171171
number_of_cache_misses: qd.number_of_cache_misses as u32,
172172
number_of_cache_hits: qd.number_of_cache_hits as u32,
173173
invocation_count: qd.invocation_count as u32,
174-
blocked_time: qd.blocked_time.as_nanos() as u64,
175-
incremental_load_time: qd.incremental_load_time.as_nanos() as u64,
174+
blocked_instructions: qd.blocked_time.as_nanos() as u64,
175+
incremental_load_instructions: qd.incremental_load_time.as_nanos() as u64,
176176
})
177177
.collect();
178178

179179
let totals = self_profile::QueryData {
180180
label: "Totals".into(),
181-
self_time: total_time.as_nanos() as u64,
181+
self_instructions: total_time.as_nanos() as u64,
182182
// TODO: check against wall-time from perf stats
183-
percent_total_time: cpu_clock
183+
percent_total_time: total_instructions
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),
@@ -199,12 +199,12 @@ fn get_self_profile_data(
199199
.iter()
200200
.map(|qd| qd.invocation_count as u32)
201201
.sum(),
202-
blocked_time: profile
202+
blocked_instructions: profile
203203
.query_data
204204
.iter()
205205
.map(|qd| qd.blocked_time.as_nanos() as u64)
206206
.sum(),
207-
incremental_load_time: profile
207+
incremental_load_instructions: profile
208208
.query_data
209209
.iter()
210210
.map(|qd| qd.incremental_load_time.as_nanos() as u64)
@@ -249,13 +249,13 @@ fn add_uninvoked_base_profile_queries(
249249
if !profile_queries.contains(qd.label.as_str()) {
250250
let uninvoked_query_data = self_profile::QueryData {
251251
label: qd.label,
252-
self_time: 0,
252+
self_instructions: 0,
253253
percent_total_time: 0.0,
254254
number_of_cache_misses: 0,
255255
number_of_cache_hits: 0,
256256
invocation_count: 0,
257-
blocked_time: 0,
258-
incremental_load_time: 0,
257+
blocked_instructions: 0,
258+
incremental_load_instructions: 0,
259259
};
260260

261261
profile.query_data.push(uninvoked_query_data);
@@ -272,11 +272,12 @@ fn get_self_profile_delta(
272272
let base_profile = base_profile.as_ref()?;
273273

274274
let totals = self_profile::QueryDataDelta {
275-
self_time: profile.totals.self_time as i64 - base_profile.totals.self_time as i64,
275+
self_time: profile.totals.self_instructions as i64
276+
- base_profile.totals.self_instructions as i64,
276277
invocation_count: profile.totals.invocation_count as i32
277278
- base_profile.totals.invocation_count as i32,
278-
incremental_load_time: profile.totals.incremental_load_time as i64
279-
- base_profile.totals.incremental_load_time as i64,
279+
incremental_load_time: profile.totals.incremental_load_instructions as i64
280+
- base_profile.totals.incremental_load_instructions as i64,
280281
};
281282

282283
let mut query_data = Vec::new();
@@ -289,19 +290,19 @@ fn get_self_profile_delta(
289290
{
290291
Some(base_qd) => {
291292
let delta = self_profile::QueryDataDelta {
292-
self_time: qd.self_time as i64 - base_qd.self_time as i64,
293+
self_time: qd.self_instructions as i64 - base_qd.self_instructions as i64,
293294
invocation_count: qd.invocation_count as i32 - base_qd.invocation_count as i32,
294-
incremental_load_time: qd.incremental_load_time as i64
295-
- base_qd.incremental_load_time as i64,
295+
incremental_load_time: qd.incremental_load_instructions as i64
296+
- base_qd.incremental_load_instructions as i64,
296297
};
297298

298299
query_data.push(delta);
299300
}
300301
None => {
301302
let delta = self_profile::QueryDataDelta {
302-
self_time: qd.self_time as i64,
303+
self_time: qd.self_instructions as i64,
303304
invocation_count: qd.invocation_count as i32,
304-
incremental_load_time: qd.incremental_load_time as i64,
305+
incremental_load_time: qd.incremental_load_instructions as i64,
305306
};
306307

307308
query_data.push(delta);
@@ -339,12 +340,12 @@ fn sort_self_profile(
339340

340341
match sort_idx.abs() {
341342
1 => indices.sort_by_key(|&i| qd[i].label),
342-
2 => indices.sort_by_key(|&i| qd[i].self_time),
343+
2 => indices.sort_by_key(|&i| qd[i].self_instructions),
343344
3 => indices.sort_by_key(|&i| qd[i].number_of_cache_misses),
344345
4 => indices.sort_by_key(|&i| qd[i].number_of_cache_hits),
345346
5 => indices.sort_by_key(|&i| qd[i].invocation_count),
346-
6 => indices.sort_by_key(|&i| qd[i].blocked_time),
347-
7 => indices.sort_by_key(|&i| qd[i].incremental_load_time),
347+
6 => indices.sort_by_key(|&i| qd[i].blocked_instructions),
348+
7 => indices.sort_by_key(|&i| qd[i].incremental_load_instructions),
348349
9 => indices.sort_by_key(|&i| {
349350
// convert to displayed percentage
350351
((qd[i].number_of_cache_hits as f64 / qd[i].invocation_count as f64) * 10_000.0) as u64
@@ -602,9 +603,9 @@ pub async fn handle_self_profile(
602603
}
603604
let commits = Arc::new(commits);
604605

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;
606+
let mut instructions_responses = ctxt.statistic_series(query, commits.clone()).await?;
607+
assert_eq!(instructions_responses.len(), 1, "all selectors are exact");
608+
let mut instructions_response = instructions_responses.remove(0).series;
608609

609610
let mut self_profile_data = Vec::new();
610611
let conn = ctxt.conn().await;
@@ -623,12 +624,16 @@ pub async fn handle_self_profile(
623624
}
624625
}
625626
let profiling_data = self_profile_data.remove(0).perform_analysis();
626-
let mut profile = get_self_profile_data(cpu_response.next().unwrap().1, &profiling_data)
627-
.map_err(|e| format!("{}: {}", body.commit, e))?;
627+
let mut profile =
628+
get_self_profile_data(instructions_response.next().unwrap().1, &profiling_data)
629+
.map_err(|e| format!("{}: {}", body.commit, e))?;
628630
let (base_profile, base_raw_data) = if body.base_commit.is_some() {
629631
let base_profiling_data = self_profile_data.remove(0).perform_analysis();
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))?;
632+
let profile = get_self_profile_data(
633+
instructions_response.next().unwrap().1,
634+
&base_profiling_data,
635+
)
636+
.map_err(|e| format!("{}: {}", body.base_commit.as_ref().unwrap(), e))?;
632637
(Some(profile), Some(base_profiling_data))
633638
} else {
634639
(None, None)

0 commit comments

Comments
 (0)