From e60ccfc6a9e91a7b26f368c9fee40bd22831450f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Tue, 31 Jan 2023 18:15:42 +0100 Subject: [PATCH] Don't inline query_cache_hit to reduce code size of the query hot path. --- compiler/rustc_data_structures/src/profiling.rs | 2 +- compiler/rustc_query_system/src/query/plumbing.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 393f1739081..20827c9fd1a 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -393,7 +393,7 @@ impl SelfProfilerRef { } /// Record a query in-memory cache hit. - #[inline(always)] + #[inline(never)] pub fn query_cache_hit(&self, query_invocation_id: QueryInvocationId) { self.instant_query_event( |profiler| profiler.query_cache_hit_event_kind, diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index ffc413d15f5..2fde3c6075b 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -722,7 +722,9 @@ where } Some((_, dep_node_index)) => { dep_graph.read_index(dep_node_index); - qcx.dep_context().profiler().query_cache_hit(dep_node_index.into()); + if std::intrinsics::unlikely(qcx.dep_context().profiler().enabled()) { + qcx.dep_context().profiler().query_cache_hit(dep_node_index.into()); + } (false, None) } }