@@ -112,11 +112,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
112
112
let mut lock = cache. borrow_mut ( ) ;
113
113
if let Some ( value) = lock. results . get ( key) {
114
114
profq_msg ! ( tcx, ProfileQueriesMsg :: CacheHit ) ;
115
- tcx. sess . profiler ( |p| {
116
- p. record_query ( Q :: CATEGORY ) ;
117
- p. record_query_hit ( Q :: CATEGORY ) ;
118
- } ) ;
119
-
115
+ tcx. sess . profiler ( |p| p. record_query_hit ( Q :: CATEGORY ) ) ;
120
116
let result = Ok ( ( value. value . clone ( ) , value. index ) ) ;
121
117
#[ cfg( debug_assertions) ]
122
118
{
@@ -195,6 +191,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
195
191
/// Executes a job by changing the ImplicitCtxt to point to the
196
192
/// new query job while it executes. It returns the diagnostics
197
193
/// captured during execution and the actual result.
194
+ #[ inline( always) ]
198
195
pub ( super ) fn start < ' lcx , F , R > (
199
196
& self ,
200
197
tcx : TyCtxt < ' _ , ' tcx , ' lcx > ,
@@ -382,13 +379,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
382
379
)
383
380
) ;
384
381
385
- self . sess . profiler ( |p| p. record_query ( Q :: CATEGORY ) ) ;
386
-
387
382
let job = match JobOwner :: try_get ( self , span, & key) {
388
383
TryGetJob :: NotYetStarted ( job) => job,
389
384
TryGetJob :: JobCompleted ( result) => {
390
385
return result. map ( |( v, index) | {
391
- self . sess . profiler ( |p| p. record_query_hit ( Q :: CATEGORY ) ) ;
392
386
self . dep_graph . read_index ( index) ;
393
387
v
394
388
} )
@@ -430,9 +424,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
430
424
431
425
if !dep_node. kind . is_input ( ) {
432
426
if let Some ( dep_node_index) = self . try_mark_green_and_read ( & dep_node) {
433
- profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
434
- self . sess . profiler ( |p| p. record_query_hit ( Q :: CATEGORY ) ) ;
435
-
436
427
return self . load_from_disk_and_cache_in_memory :: < Q > ( key,
437
428
job,
438
429
dep_node_index,
@@ -483,11 +474,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
483
474
} ;
484
475
485
476
let result = if let Some ( result) = result {
477
+ profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
478
+ self . sess . profiler ( |p| p. record_query_hit ( Q :: CATEGORY ) ) ;
479
+
486
480
result
487
481
} else {
488
482
// We could not load a result from the on-disk cache, so
489
483
// recompute.
490
484
485
+ self . sess . profiler ( |p| p. start_activity ( Q :: CATEGORY ) ) ;
486
+
491
487
// The diagnostics for this query have already been
492
488
// promoted to the current session during
493
489
// try_mark_green(), so we can ignore them here.
@@ -498,6 +494,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
498
494
Q :: compute ( tcx, key)
499
495
} )
500
496
} ) ;
497
+
498
+ self . sess . profiler ( |p| p. end_activity ( Q :: CATEGORY ) ) ;
501
499
result
502
500
} ;
503
501
@@ -547,6 +545,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
547
545
for {:?}", dep_node) ;
548
546
}
549
547
548
+ #[ inline( always) ]
550
549
fn force_query_with_job < Q : QueryDescription < ' gcx > > (
551
550
self ,
552
551
key : Q :: Key ,
@@ -565,10 +564,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
565
564
key, dep_node) ;
566
565
567
566
profq_msg ! ( self , ProfileQueriesMsg :: ProviderBegin ) ;
568
- self . sess . profiler ( |p| {
569
- p. start_activity ( Q :: CATEGORY ) ;
570
- p. record_query ( Q :: CATEGORY ) ;
571
- } ) ;
567
+ self . sess . profiler ( |p| p. start_activity ( Q :: CATEGORY ) ) ;
572
568
573
569
let res = job. start ( self , |tcx| {
574
570
if dep_node. kind . is_eval_always ( ) {
@@ -624,14 +620,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
624
620
// this introduces should be negligible as we'll immediately hit the
625
621
// in-memory cache, or another query down the line will.
626
622
627
- self . sess . profiler ( |p| {
628
- p. start_activity ( Q :: CATEGORY ) ;
629
- p. record_query ( Q :: CATEGORY ) ;
630
- } ) ;
631
-
632
623
let _ = self . get_query :: < Q > ( DUMMY_SP , key) ;
633
-
634
- self . sess . profiler ( |p| p. end_activity ( Q :: CATEGORY ) ) ;
624
+ } else {
625
+ profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
626
+ self . sess . profiler ( |p| p. record_query_hit ( Q :: CATEGORY ) ) ;
635
627
}
636
628
}
637
629
@@ -751,6 +743,17 @@ macro_rules! define_queries_inner {
751
743
}
752
744
}
753
745
746
+ pub fn record_computed_queries( & self , sess: & Session ) {
747
+ sess. profiler( |p| {
748
+ $(
749
+ p. record_computed_queries(
750
+ <queries:: $name<' _> as QueryConfig <' _>>:: CATEGORY ,
751
+ self . $name. lock( ) . results. len( )
752
+ ) ;
753
+ ) *
754
+ } ) ;
755
+ }
756
+
754
757
#[ cfg( parallel_queries) ]
755
758
pub fn collect_active_jobs( & self ) -> Vec <Lrc <QueryJob <$tcx>>> {
756
759
let mut jobs = Vec :: new( ) ;
0 commit comments