Skip to content

Commit 91c55e7

Browse files
Avoid storing cache misses
This duplicates information that is already present in the cache hits and invocation counters; there's no need to duplicate the information.
1 parent 3022ff5 commit 91c55e7

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

collector/src/self_profile.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ impl Into<InternalSelfProfile> for SelfProfile {
1919
.iter()
2020
.map(|qd| u64::try_from(qd.self_time.as_nanos()).unwrap())
2121
.collect(),
22-
number_of_cache_misses: query_data
23-
.iter()
24-
.map(|qd| qd.number_of_cache_misses)
25-
.collect(),
2622
number_of_cache_hits: query_data
2723
.iter()
2824
.map(|qd| qd.number_of_cache_hits)
@@ -52,7 +48,6 @@ impl From<InternalSelfProfile> for SelfProfile {
5248
InternalSelfProfile::Perf {
5349
label,
5450
self_time,
55-
number_of_cache_misses,
5651
number_of_cache_hits,
5752
invocation_count,
5853
blocked_time,
@@ -61,7 +56,6 @@ impl From<InternalSelfProfile> for SelfProfile {
6156
let mut query_data = Vec::with_capacity(label.len());
6257
let label = label.into_iter();
6358
let mut self_time = self_time.into_iter().map(from_nanoseconds_to_duration);
64-
let mut number_of_cache_misses = number_of_cache_misses.into_iter();
6559
let mut number_of_cache_hits = number_of_cache_hits.into_iter();
6660
let mut invocation_count = invocation_count.into_iter();
6761
let mut blocked_time = blocked_time.into_iter().map(from_nanoseconds_to_duration);
@@ -72,7 +66,6 @@ impl From<InternalSelfProfile> for SelfProfile {
7266
query_data.push(QueryData {
7367
label,
7468
self_time: self_time.next().unwrap(),
75-
number_of_cache_misses: number_of_cache_misses.next().unwrap(),
7669
number_of_cache_hits: number_of_cache_hits.next().unwrap(),
7770
invocation_count: invocation_count.next().unwrap(),
7871
blocked_time: blocked_time.next().unwrap(),
@@ -91,14 +84,14 @@ impl From<InternalSelfProfile> for SelfProfile {
9184
#[derive(Serialize, Deserialize)]
9285
#[serde(untagged)]
9386
enum InternalSelfProfile {
94-
Rustc {
95-
query_data: Vec<QueryData>,
96-
},
87+
// We don't want to serialize in the verbose format,
88+
// it's too big.
89+
#[serde(skip_serializing)]
90+
Rustc { query_data: Vec<QueryData> },
9791
Perf {
9892
label: Vec<QueryLabel>,
9993
// nanos
10094
self_time: Vec<u64>,
101-
number_of_cache_misses: Vec<u32>,
10295
number_of_cache_hits: Vec<u32>,
10396
invocation_count: Vec<u32>,
10497
// nanos
@@ -119,15 +112,20 @@ fn from_nanoseconds_to_duration(nanos: u64) -> Duration {
119112
)
120113
}
121114

122-
#[derive(Serialize, Deserialize, Clone, Debug)]
115+
#[derive(Deserialize, Clone, Debug)]
123116
pub struct QueryData {
124117
pub label: QueryLabel,
125118
pub self_time: Duration,
126-
pub number_of_cache_misses: u32,
127119
pub number_of_cache_hits: u32,
128120
pub invocation_count: u32,
129121
pub blocked_time: Duration,
130122
pub incremental_load_time: Duration,
131123
}
132124

125+
impl QueryData {
126+
pub fn number_of_cache_misses(&self) -> u32 {
127+
self.invocation_count - self.number_of_cache_hits
128+
}
129+
}
130+
133131
crate::intern!(pub struct QueryLabel);

site/src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ fn get_self_profile_data(
666666
number_of_cache_misses: profile
667667
.query_data
668668
.iter()
669-
.map(|qd| qd.number_of_cache_misses)
669+
.map(|qd| qd.number_of_cache_misses())
670670
.sum(),
671671
number_of_cache_hits: profile
672672
.query_data
@@ -695,7 +695,7 @@ fn get_self_profile_data(
695695
percent_total_time: ((qd.self_time.as_nanos() as f64
696696
/ totals.self_time.as_nanos() as f64)
697697
* 100.0) as f32,
698-
number_of_cache_misses: qd.number_of_cache_misses,
698+
number_of_cache_misses: qd.number_of_cache_misses(),
699699
number_of_cache_hits: qd.number_of_cache_hits,
700700
invocation_count: qd.invocation_count,
701701
blocked_time: qd.blocked_time,

0 commit comments

Comments
 (0)