@@ -7,6 +7,16 @@ use std::path::PathBuf;
7
7
use std:: process:: Command ;
8
8
use std:: time:: { Duration , Instant } ;
9
9
10
+ fn determinism_env ( cmd : & mut Command ) {
11
+ // Since rust-lang/rust#89836, rustc stable crate IDs include a hash of the
12
+ // rustc version (including the git commit it's built from), which means
13
+ // that hashmaps or other structures have different behavior when comparing
14
+ // different rustc builds. This is bad for rustc-perf, as it means that
15
+ // comparing two commits has a source of noise that makes it harder to know
16
+ // what the actual change between two artifacts is.
17
+ cmd. env ( "RUSTC_FORCE_INCR_COMP_ARTIFACT_HEADER" , "rustc-perf" ) ;
18
+ }
19
+
10
20
fn main ( ) {
11
21
let mut args_os = env:: args_os ( ) ;
12
22
let name = args_os. next ( ) . unwrap ( ) . into_string ( ) . unwrap ( ) ;
@@ -30,6 +40,14 @@ fn main() {
30
40
31
41
args. push ( OsString :: from ( "-Adeprecated" ) ) ;
32
42
args. push ( OsString :: from ( "-Aunknown-lints" ) ) ;
43
+
44
+ // This forces incremental query hash verification on. Currently, rustc
45
+ // hashes 1/32 of queries loaded from disk without this flag, but that 1/32
46
+ // is based on the (expected) hash of the data, which can vary from build to
47
+ // build, adding a source of noise to our measurements, which we prefer to
48
+ // avoid. rustc-perf can accept the higher cost of always verifying hashes,
49
+ // and we currently prefer to avoid exposing a means of hard-disabling
50
+ // verification.
33
51
args. push ( OsString :: from ( "-Zincremental-verify-ich" ) ) ;
34
52
35
53
if let Some ( pos) = args. iter ( ) . position ( |arg| arg == "--wrap-rustc-with" ) {
@@ -44,6 +62,7 @@ fn main() {
44
62
match wrapper {
45
63
"perf-stat" | "perf-stat-self-profile" => {
46
64
let mut cmd = Command :: new ( "perf" ) ;
65
+ determinism_env ( & mut cmd) ;
47
66
let has_perf = cmd. output ( ) . is_ok ( ) ;
48
67
assert ! ( has_perf) ;
49
68
cmd. arg ( "stat" )
@@ -121,6 +140,7 @@ fn main() {
121
140
assert ! ( status. success( ) , "tracelog did not complete successfully" ) ;
122
141
123
142
let mut tool = Command :: new ( tool) ;
143
+ determinism_env ( & mut tool) ;
124
144
tool. args ( & args) ;
125
145
126
146
let prof_out_dir = std:: env:: current_dir ( ) . unwrap ( ) . join ( "self-profile-output" ) ;
@@ -162,6 +182,7 @@ fn main() {
162
182
163
183
"self-profile" => {
164
184
let mut cmd = Command :: new ( & tool) ;
185
+ determinism_env ( & mut cmd) ;
165
186
cmd. arg ( "-Zself-profile-events=all" ) ;
166
187
cmd. arg ( "-Zself-profile=Zsp" ) . args ( & args) ;
167
188
@@ -172,6 +193,7 @@ fn main() {
172
193
args. insert ( 0 , "-Ztime-passes" . into ( ) ) ;
173
194
174
195
let mut cmd = Command :: new ( & tool) ;
196
+ determinism_env ( & mut cmd) ;
175
197
cmd. args ( args) . stderr ( std:: process:: Stdio :: from (
176
198
std:: fs:: File :: create ( "Ztp" ) . unwrap ( ) ,
177
199
) ) ;
@@ -180,6 +202,7 @@ fn main() {
180
202
181
203
"perf-record" => {
182
204
let mut cmd = Command :: new ( "perf" ) ;
205
+ determinism_env ( & mut cmd) ;
183
206
let has_perf = cmd. output ( ) . is_ok ( ) ;
184
207
assert ! ( has_perf) ;
185
208
cmd. arg ( "record" )
@@ -195,6 +218,7 @@ fn main() {
195
218
196
219
"oprofile" => {
197
220
let mut cmd = Command :: new ( "operf" ) ;
221
+ determinism_env ( & mut cmd) ;
198
222
let has_oprofile = cmd. output ( ) . is_ok ( ) ;
199
223
assert ! ( has_oprofile) ;
200
224
// Other possibly useful args: --callgraph, --separate-thread
@@ -205,6 +229,7 @@ fn main() {
205
229
206
230
"cachegrind" => {
207
231
let mut cmd = Command :: new ( "valgrind" ) ;
232
+ determinism_env ( & mut cmd) ;
208
233
let has_valgrind = cmd. output ( ) . is_ok ( ) ;
209
234
assert ! ( has_valgrind) ;
210
235
@@ -229,6 +254,7 @@ fn main() {
229
254
230
255
"callgrind" => {
231
256
let mut cmd = Command :: new ( "valgrind" ) ;
257
+ determinism_env ( & mut cmd) ;
232
258
let has_valgrind = cmd. output ( ) . is_ok ( ) ;
233
259
assert ! ( has_valgrind) ;
234
260
@@ -246,6 +272,7 @@ fn main() {
246
272
247
273
"dhat" => {
248
274
let mut cmd = Command :: new ( "valgrind" ) ;
275
+ determinism_env ( & mut cmd) ;
249
276
let has_valgrind = cmd. output ( ) . is_ok ( ) ;
250
277
assert ! ( has_valgrind) ;
251
278
cmd. arg ( "--tool=dhat" )
@@ -259,6 +286,7 @@ fn main() {
259
286
260
287
"massif" => {
261
288
let mut cmd = Command :: new ( "valgrind" ) ;
289
+ determinism_env ( & mut cmd) ;
262
290
let has_valgrind = cmd. output ( ) . is_ok ( ) ;
263
291
assert ! ( has_valgrind) ;
264
292
cmd. arg ( "--tool=massif" )
@@ -275,6 +303,7 @@ fn main() {
275
303
276
304
"eprintln" => {
277
305
let mut cmd = bash_command ( tool, args, "2> eprintln" ) ;
306
+ determinism_env ( & mut cmd) ;
278
307
279
308
assert ! ( cmd. status( ) . expect( "failed to spawn" ) . success( ) ) ;
280
309
}
@@ -288,6 +317,7 @@ fn main() {
288
317
// `rustc` (which this file wraps) doesn't produce the output,
289
318
// this file can't redirect that output.
290
319
let mut cmd = Command :: new ( & tool) ;
320
+ determinism_env ( & mut cmd) ;
291
321
cmd. args ( & args) ;
292
322
293
323
assert ! ( cmd. status( ) . expect( "failed to spawn" ) . success( ) ) ;
@@ -298,6 +328,7 @@ fn main() {
298
328
// option)
299
329
args. push ( "-Zprint-mono-items=lazy" . into ( ) ) ;
300
330
let mut cmd = bash_command ( tool, args, "1> mono-items" ) ;
331
+ determinism_env ( & mut cmd) ;
301
332
302
333
assert ! ( cmd. status( ) . expect( "failed to spawn" ) . success( ) ) ;
303
334
}
@@ -306,6 +337,7 @@ fn main() {
306
337
args. push ( "-Zdump-dep-graph" . into ( ) ) ;
307
338
args. push ( "-Zquery-dep-graph" . into ( ) ) ;
308
339
let mut cmd = Command :: new ( tool) ;
340
+ determinism_env ( & mut cmd) ;
309
341
cmd. args ( & args) ;
310
342
311
343
assert ! ( cmd. status( ) . expect( "failed to spawn" ) . success( ) ) ;
@@ -332,6 +364,7 @@ fn main() {
332
364
}
333
365
334
366
let mut cmd = Command :: new ( & tool) ;
367
+ determinism_env ( & mut cmd) ;
335
368
cmd. args ( & args) ;
336
369
exec ( & mut cmd) ;
337
370
}
0 commit comments