Tweak query code for performance#56613
Conversation
| pub use rustc_serialize::hex::ToHex; | ||
|
|
||
| #[macro_export] | ||
| macro_rules! likely { |
There was a problem hiding this comment.
It gets used in #56614. Might as well add them both
|
@bors try |
Tweak query code for performance Split from #56509 r? @michaelwoerister
| if self.opts.debugging_opts.self_profile || self.opts.debugging_opts.profile_json { | ||
| let mut profiler = self.self_profiling.borrow_mut(); | ||
| f(&mut profiler); | ||
| if unlikely!(self.self_profiling_active) { |
There was a problem hiding this comment.
LLVM already assigns reduced branch weights to branches postdominated by calls to cold functions, so I wouldn't expect this unlikely!() to have an effect here.
There was a problem hiding this comment.
I did find a case where it didn't though, so I used likely and unlikely just in case.
There was a problem hiding this comment.
I'd really like to have PGO for the Rust compiler at some point :)
|
☀️ Test successful - status-travis |
|
@rust-timer build c89a860 |
|
Success: Queued c89a860 with parent 9567a1c, comparison URL. |
|
Finished benchmarking try commit c89a860 |
| &self.krate | ||
| } | ||
|
|
||
| pub fn untracked_krate<'hir>(&'hir self) -> &'hir Crate { |
There was a problem hiding this comment.
Please add a warning comment here not to use this function and that it only exists for internal use with the dep-tracking system.
| { | ||
| if let Err(cycle) = job.await(tcx, span) { | ||
| return TryGetJob::JobCompleted(Err(cycle)); | ||
| } |
There was a problem hiding this comment.
I think the following would be more readable:
if cfg!(parallel_queries) {
if let Err(cycle) = job.await(tcx, span) {
return TryGetJob::JobCompleted(Err(cycle));
}
} else {
// If we get here in non-parallel mode we know that we have cycle error.
let result = job.await(tcx, span);
debug_assert!(result.is_err());
return result;
}There was a problem hiding this comment.
That doesn't work since await now has different signatures depending on cfg!(parallel_queries). I'll add the comment though.
| #[inline(always)] | ||
| pub fn from_def_path_hash(kind: DepKind, | ||
| def_path_hash: DefPathHash) | ||
| -> DepNode { |
There was a problem hiding this comment.
You can turn the assertion below into a debug_assertion.
src/librustc/dep_graph/dep_node.rs
Outdated
There was a problem hiding this comment.
This can be turned into a debug_assertion too.
src/librustc/dep_graph/dep_node.rs
Outdated
There was a problem hiding this comment.
Why are is_input and has_params split but not is_anon and is_eval_always? I'd prefer not to split them into two methods. Maybe, with some of the assertions in here turned into debug-assertions, a regular #[inline] would suffice.
There was a problem hiding this comment.
is_anon and is_eval_always has uses where inlining them might not be beneficial. A regular #[inline] does not suffice since these are large functions and LLVM won't inline them unless you tell it to. I use the *_inlined variants for calls when LLVM can optimize it all away.
I want to turn these properties into associated constants anyway, but that is blocked on #56462.
There was a problem hiding this comment.
I think switching to debug_assertions will remove most of the hot calls to those functions. Since they might be replaced soon anyway, I'd prefer not to split the functions in order to avoid churn. You can just mark them as #[inline(always)] if performance is bad otherwise.
|
Thanks, @Zoxc! I left some comments. You could also try to turn |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
📌 Commit 64d54e61b70245c0aa660c888c7545206ca872b1 has been approved by |
|
⌛ Testing commit 64d54e61b70245c0aa660c888c7545206ca872b1 with merge fd5abe90bc2c0934babdd742ace6d7618035d0e2... |
|
💔 Test failed - status-appveyor |
|
Hmm.. a crash, maybe |
|
@bors r=michaelwoerister |
|
📌 Commit f0adf5a has been approved by |
Tweak query code for performance Split from #56509 r? @michaelwoerister
|
☀️ Test successful - status-appveyor, status-travis |
Split from #56509
r? @michaelwoerister