Move iter_results to dyn FnMut rather than a generic
This means that we're no longer generating the iteration/locking code for each invocation site of iter_results, rather just once per query. This is a 15% win in instruction counts when compiling the rustc_query_impl crate.
This commit is contained in:
parent
c488f15700
commit
a1d7367429
5 changed files with 53 additions and 47 deletions
|
@ -250,8 +250,8 @@ fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>(
|
|||
// need to invoke queries itself, we cannot keep the query caches
|
||||
// locked while doing so. Instead we copy out the
|
||||
// `(query_key, dep_node_index)` pairs and release the lock again.
|
||||
let query_keys_and_indices: Vec<_> = query_cache
|
||||
.iter_results(|results| results.map(|(k, _, i)| (k.clone(), i)).collect());
|
||||
let mut query_keys_and_indices = Vec::new();
|
||||
query_cache.iter_results(&mut |k, _, i| query_keys_and_indices.push((k.clone(), i)));
|
||||
|
||||
// Now actually allocate the strings. If allocating the strings
|
||||
// generates new entries in the query cache, we'll miss them but
|
||||
|
@ -275,14 +275,15 @@ fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>(
|
|||
let query_name = profiler.get_or_alloc_cached_string(query_name);
|
||||
let event_id = event_id_builder.from_label(query_name).to_string_id();
|
||||
|
||||
query_cache.iter_results(|results| {
|
||||
let query_invocation_ids: Vec<_> = results.map(|v| v.2.into()).collect();
|
||||
|
||||
profiler.bulk_map_query_invocation_id_to_single_string(
|
||||
query_invocation_ids.into_iter(),
|
||||
event_id,
|
||||
);
|
||||
let mut query_invocation_ids = Vec::new();
|
||||
query_cache.iter_results(&mut |_, _, i| {
|
||||
query_invocation_ids.push(i.into());
|
||||
});
|
||||
|
||||
profiler.bulk_map_query_invocation_id_to_single_string(
|
||||
query_invocation_ids.into_iter(),
|
||||
event_id,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -50,13 +50,12 @@ where
|
|||
key_type: type_name::<C::Key>(),
|
||||
value_size: mem::size_of::<C::Value>(),
|
||||
value_type: type_name::<C::Value>(),
|
||||
entry_count: map.iter_results(|results| results.count()),
|
||||
entry_count: 0,
|
||||
local_def_id_keys: None,
|
||||
};
|
||||
map.iter_results(|results| {
|
||||
for (key, _, _) in results {
|
||||
key.key_stats(&mut stats)
|
||||
}
|
||||
map.iter_results(&mut |key, _, _| {
|
||||
stats.entry_count += 1;
|
||||
key.key_stats(&mut stats)
|
||||
});
|
||||
stats
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue