-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix and optimize query profiling #57095
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
@bors try |
⌛ Trying commit 7c985beec1d57f2bfe6890f47eeab641c879ece3 with merge e12bb21de0cda2992dd77eb54755b113dea148f5... |
☀️ Test successful - status-travis |
@rust-timer build e12bb21de0cda2992dd77eb54755b113dea148f5 |
Success: Queued e12bb21de0cda2992dd77eb54755b113dea148f5 with parent 94bf2c1, comparison URL. |
Finished benchmarking try commit e12bb21de0cda2992dd77eb54755b113dea148f5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @Zoxc! Good idea to record query counts in bulk.
r=me with the functions renamed.
src/librustc/ty/query/plumbing.rs
Outdated
@@ -742,6 +734,17 @@ macro_rules! define_queries_inner { | |||
} | |||
} | |||
|
|||
pub fn record_query_hits(&self, sess: &Session) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called something like record_queries_computed
unless I'm misreading something.
src/librustc/util/profiling.rs
Outdated
pub fn record_query(&mut self, category: ProfileCategory) { | ||
let (hits, total) = *self.data.query_counts.get(category); | ||
self.data.query_counts.set(category, (hits, total + 1)); | ||
pub fn record_queries(&mut self, category: ProfileCategory, count: usize) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should renamed to record_queries_computed
too then.
result | ||
} else { | ||
// We could not load a result from the on-disk cache, so | ||
// recompute. | ||
|
||
self.sess.profiler(|p| p.start_activity(Q::CATEGORY)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a remark: There should probably be a third category here for things that could be re-used but are not stored in the cache. Not sure how to best handle this.
self.data.query_counts.set(category, (hits, total + 1)); | ||
pub fn record_queries(&mut self, category: ProfileCategory, count: usize) { | ||
let (hits, computed) = *self.data.query_counts.get(category); | ||
self.data.query_counts.set(category, (hits, computed + count as u64)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An issue for another PR: This looks like we could get missed updates here (and below) with parallel queries.
@bors r=michaelwoerister |
📌 Commit 23c742c has been approved by |
Fix and optimize query profiling r? @michaelwoerister cc @wesleywiser
☀️ Test successful - status-appveyor, status-travis |
r? @michaelwoerister
cc @wesleywiser