@@ -55,6 +55,7 @@ use std::io::Write;
55
55
use std:: path:: { Path , PathBuf } ;
56
56
use std:: time:: Duration ;
57
57
use std:: sync:: mpsc;
58
+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
58
59
59
60
mod code_stats;
60
61
pub mod config;
@@ -165,27 +166,16 @@ pub struct Session {
165
166
}
166
167
167
168
pub struct PerfStats {
168
- /// The accumulated time needed for computing the SVH of the crate
169
- pub svh_time : Cell < Duration > ,
170
- /// The accumulated time spent on computing incr. comp. hashes
171
- pub incr_comp_hashes_time : Cell < Duration > ,
172
- /// The number of incr. comp. hash computations performed
173
- pub incr_comp_hashes_count : Cell < u64 > ,
174
- /// The number of bytes hashed when computing ICH values
175
- pub incr_comp_bytes_hashed : Cell < u64 > ,
176
169
/// The accumulated time spent on computing symbol hashes
177
- pub symbol_hash_time : Cell < Duration > ,
170
+ pub symbol_hash_time : Lock < Duration > ,
178
171
/// The accumulated time spent decoding def path tables from metadata
179
- pub decode_def_path_tables_time : Cell < Duration > ,
172
+ pub decode_def_path_tables_time : Lock < Duration > ,
180
173
/// Total number of values canonicalized queries constructed.
181
- pub queries_canonicalized : Cell < usize > ,
182
- /// Number of times we canonicalized a value and found that the
183
- /// result had already been canonicalized.
184
- pub canonicalized_values_allocated : Cell < usize > ,
174
+ pub queries_canonicalized : AtomicUsize ,
185
175
/// Number of times this query is invoked.
186
- pub normalize_ty_after_erasing_regions : Cell < usize > ,
176
+ pub normalize_ty_after_erasing_regions : AtomicUsize ,
187
177
/// Number of times this query is invoked.
188
- pub normalize_projection_ty : Cell < usize > ,
178
+ pub normalize_projection_ty : AtomicUsize ,
189
179
}
190
180
191
181
/// Enum to support dispatch of one-time diagnostics (in Session.diag_once)
@@ -838,47 +828,20 @@ impl Session {
838
828
}
839
829
840
830
pub fn print_perf_stats ( & self ) {
841
- println ! (
842
- "Total time spent computing SVHs: {}" ,
843
- duration_to_secs_str( self . perf_stats. svh_time. get( ) )
844
- ) ;
845
- println ! (
846
- "Total time spent computing incr. comp. hashes: {}" ,
847
- duration_to_secs_str( self . perf_stats. incr_comp_hashes_time. get( ) )
848
- ) ;
849
- println ! (
850
- "Total number of incr. comp. hashes computed: {}" ,
851
- self . perf_stats. incr_comp_hashes_count. get( )
852
- ) ;
853
- println ! (
854
- "Total number of bytes hashed for incr. comp.: {}" ,
855
- self . perf_stats. incr_comp_bytes_hashed. get( )
856
- ) ;
857
- if self . perf_stats . incr_comp_hashes_count . get ( ) != 0 {
858
- println ! (
859
- "Average bytes hashed per incr. comp. HIR node: {}" ,
860
- self . perf_stats. incr_comp_bytes_hashed. get( )
861
- / self . perf_stats. incr_comp_hashes_count. get( )
862
- ) ;
863
- } else {
864
- println ! ( "Average bytes hashed per incr. comp. HIR node: N/A" ) ;
865
- }
866
831
println ! (
867
832
"Total time spent computing symbol hashes: {}" ,
868
- duration_to_secs_str( self . perf_stats. symbol_hash_time. get ( ) )
833
+ duration_to_secs_str( * self . perf_stats. symbol_hash_time. lock ( ) )
869
834
) ;
870
835
println ! (
871
836
"Total time spent decoding DefPath tables: {}" ,
872
- duration_to_secs_str( self . perf_stats. decode_def_path_tables_time. get ( ) )
837
+ duration_to_secs_str( * self . perf_stats. decode_def_path_tables_time. lock ( ) )
873
838
) ;
874
839
println ! ( "Total queries canonicalized: {}" ,
875
- self . perf_stats. queries_canonicalized. get( ) ) ;
876
- println ! ( "Total canonical values interned: {}" ,
877
- self . perf_stats. canonicalized_values_allocated. get( ) ) ;
840
+ self . perf_stats. queries_canonicalized. load( Ordering :: Relaxed ) ) ;
878
841
println ! ( "normalize_ty_after_erasing_regions: {}" ,
879
- self . perf_stats. normalize_ty_after_erasing_regions. get ( ) ) ;
842
+ self . perf_stats. normalize_ty_after_erasing_regions. load ( Ordering :: Relaxed ) ) ;
880
843
println ! ( "normalize_projection_ty: {}" ,
881
- self . perf_stats. normalize_projection_ty. get ( ) ) ;
844
+ self . perf_stats. normalize_projection_ty. load ( Ordering :: Relaxed ) ) ;
882
845
}
883
846
884
847
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
@@ -1160,16 +1123,11 @@ pub fn build_session_(
1160
1123
ignored_attr_names : ich:: compute_ignored_attr_names ( ) ,
1161
1124
profile_channel : Lock :: new ( None ) ,
1162
1125
perf_stats : PerfStats {
1163
- svh_time : Cell :: new ( Duration :: from_secs ( 0 ) ) ,
1164
- incr_comp_hashes_time : Cell :: new ( Duration :: from_secs ( 0 ) ) ,
1165
- incr_comp_hashes_count : Cell :: new ( 0 ) ,
1166
- incr_comp_bytes_hashed : Cell :: new ( 0 ) ,
1167
- symbol_hash_time : Cell :: new ( Duration :: from_secs ( 0 ) ) ,
1168
- decode_def_path_tables_time : Cell :: new ( Duration :: from_secs ( 0 ) ) ,
1169
- queries_canonicalized : Cell :: new ( 0 ) ,
1170
- canonicalized_values_allocated : Cell :: new ( 0 ) ,
1171
- normalize_ty_after_erasing_regions : Cell :: new ( 0 ) ,
1172
- normalize_projection_ty : Cell :: new ( 0 ) ,
1126
+ symbol_hash_time : Lock :: new ( Duration :: from_secs ( 0 ) ) ,
1127
+ decode_def_path_tables_time : Lock :: new ( Duration :: from_secs ( 0 ) ) ,
1128
+ queries_canonicalized : AtomicUsize :: new ( 0 ) ,
1129
+ normalize_ty_after_erasing_regions : AtomicUsize :: new ( 0 ) ,
1130
+ normalize_projection_ty : AtomicUsize :: new ( 0 ) ,
1173
1131
} ,
1174
1132
code_stats : RefCell :: new ( CodeStats :: new ( ) ) ,
1175
1133
optimization_fuel_crate,
0 commit comments