Skip to content

Commit ca49d9e

Browse files
authored
Merge pull request #166 from rylev/incremental-hashing-timing
Handle new self-profiling information for incr-comp hash fingerprints
2 parents 2993875 + 8cedb36 commit ca49d9e

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

measureme/src/rustc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub const GENERIC_ACTIVITY_EVENT_KIND: &str = "GenericActivity";
66

77
pub const INCREMENTAL_LOAD_RESULT_EVENT_KIND: &str = "IncrementalLoadResult";
88

9+
pub const INCREMENTAL_RESULT_HASHING_EVENT_KIND: &str = "IncrementalResultHashing";
10+
911
pub const QUERY_BLOCKED_EVENT_KIND: &str = "QueryBlocked";
1012

1113
pub const QUERY_CACHE_HIT_EVENT_KIND: &str = "QueryCacheHit";

summarize/src/analysis.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ pub fn perform_analysis(data: ProfilingData) -> Results {
174174
QUERY_EVENT_KIND | GENERIC_ACTIVITY_EVENT_KIND => {
175175
data.self_time -= current_event_duration;
176176
}
177+
INCREMENTAL_RESULT_HASHING_EVENT_KIND => {
178+
// We are within hashing something. If we now encounter something
179+
// within that event (like the nested "intern-the-dep-node" event)
180+
// then we don't want to attribute that to the hashing time.
181+
data.self_time -= current_event_duration;
182+
data.incremental_hashing_time -= current_event_duration;
183+
}
177184
INCREMENTAL_LOAD_RESULT_EVENT_KIND => {
178185
data.self_time -= current_event_duration;
179186
data.incremental_load_time -= current_event_duration;
@@ -216,6 +223,16 @@ pub fn perform_analysis(data: ProfilingData) -> Results {
216223
});
217224
}
218225

226+
INCREMENTAL_RESULT_HASHING_EVENT_KIND => {
227+
record_event_data(&current_event.label, &|data| {
228+
// Don't add to data.time since this event happens
229+
// within the query itself which is already contributing
230+
// to data.time
231+
data.self_time += current_event_duration;
232+
data.incremental_hashing_time += current_event_duration;
233+
});
234+
}
235+
219236
_ => {
220237
// Data sources other than rustc will use their own event kinds so just
221238
// treat this like a GENERIC_ACTIVITY except that we don't track cache

summarize/src/main.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ fn diff(opt: DiffOpt) -> Result<(), Box<dyn Error + Send + Sync>> {
120120
"Item count",
121121
"Cache hits",
122122
"Blocked time",
123-
"Incremental load time"
123+
"Incremental load time",
124+
"Incremental hashing time",
124125
));
125126

126127
for query_data in results.query_data {
@@ -139,6 +140,7 @@ fn diff(opt: DiffOpt) -> Result<(), Box<dyn Error + Send + Sync>> {
139140
format!("{:+}", query_data.number_of_cache_hits),
140141
format!("{:.2?}", query_data.blocked_time),
141142
format!("{:.2?}", query_data.incremental_load_time),
143+
format!("{:.2?}", query_data.incremental_hashing_time),
142144
]);
143145
}
144146

@@ -180,6 +182,7 @@ fn summarize(opt: SummarizeOpt) -> Result<(), Box<dyn Error + Send + Sync>> {
180182
let mut has_cache_hits = false;
181183
let mut has_blocked_time = false;
182184
let mut has_incremental_load_time = false;
185+
let mut has_incremental_hashing_time = false;
183186

184187
let duration_zero = Duration::from_secs(0);
185188
for r in &results.query_data {
@@ -193,6 +196,10 @@ fn summarize(opt: SummarizeOpt) -> Result<(), Box<dyn Error + Send + Sync>> {
193196
has_incremental_load_time = true;
194197
}
195198

199+
if r.incremental_hashing_time > duration_zero {
200+
has_incremental_hashing_time = true;
201+
}
202+
196203
if has_cache_hits && has_blocked_time && has_incremental_load_time {
197204
break;
198205
}
@@ -209,6 +216,10 @@ fn summarize(opt: SummarizeOpt) -> Result<(), Box<dyn Error + Send + Sync>> {
209216
("Cache hits", has_cache_hits),
210217
("Blocked time", has_blocked_time),
211218
("Incremental load time", has_incremental_load_time),
219+
(
220+
"Incremental result hashing time",
221+
has_incremental_hashing_time,
222+
),
212223
];
213224

214225
fn filter_cells(cells: &[(&str, bool)]) -> Vec<Cell> {
@@ -252,6 +263,10 @@ fn summarize(opt: SummarizeOpt) -> Result<(), Box<dyn Error + Send + Sync>> {
252263
&format!("{:.2?}", query_data.incremental_load_time),
253264
has_incremental_load_time,
254265
),
266+
(
267+
&format!("{:.2?}", query_data.incremental_hashing_time),
268+
has_incremental_hashing_time,
269+
),
255270
])));
256271
}
257272

summarize/src/query_data.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct QueryData {
1313
pub invocation_count: usize,
1414
pub blocked_time: Duration,
1515
pub incremental_load_time: Duration,
16+
pub incremental_hashing_time: Duration,
1617
}
1718

1819
impl QueryData {
@@ -26,6 +27,7 @@ impl QueryData {
2627
invocation_count: 0,
2728
blocked_time: Duration::from_nanos(0),
2829
incremental_load_time: Duration::from_nanos(0),
30+
incremental_hashing_time: Duration::from_nanos(0),
2931
}
3032
}
3133

@@ -48,6 +50,7 @@ impl QueryData {
4850
invocation_count: -(self.invocation_count as i64),
4951
blocked_time: invert(self.blocked_time),
5052
incremental_load_time: invert(self.incremental_load_time),
53+
incremental_hashing_time: invert(self.incremental_hashing_time),
5154
}
5255
}
5356

@@ -63,6 +66,7 @@ impl QueryData {
6366
invocation_count: self.invocation_count as i64,
6467
blocked_time: self.blocked_time.into(),
6568
incremental_load_time: self.incremental_load_time.into(),
69+
incremental_hashing_time: self.incremental_hashing_time.into(),
6670
}
6771
}
6872
}
@@ -79,6 +83,7 @@ pub struct QueryDataDiff {
7983
pub invocation_count: i64,
8084
pub blocked_time: SignedDuration,
8185
pub incremental_load_time: SignedDuration,
86+
pub incremental_hashing_time: SignedDuration,
8287
}
8388

8489
impl Sub for QueryData {
@@ -106,6 +111,8 @@ impl Sub for QueryData {
106111
invocation_count: i(self.invocation_count) - i(rhs.invocation_count),
107112
blocked_time: sd(self.blocked_time) - sd(rhs.blocked_time),
108113
incremental_load_time: sd(self.incremental_load_time) - sd(rhs.incremental_load_time),
114+
incremental_hashing_time: sd(self.incremental_hashing_time)
115+
- sd(rhs.incremental_hashing_time),
109116
}
110117
}
111118
}

0 commit comments

Comments
 (0)