@@ -149,6 +149,104 @@ where
149
149
Ok ( v)
150
150
}
151
151
152
+ fn process_commits (
153
+ out_repo : outrepo:: Repo ,
154
+ benchmarks : & [ Benchmark ] ,
155
+ collect_self_profile : bool ,
156
+ ) -> Result < ( ) , Error > {
157
+ println ! ( "processing commits" ) ;
158
+ let client = reqwest:: Client :: new ( ) ;
159
+ let commit: Option < String > = client
160
+ . get ( & format ! (
161
+ "{}/perf/next_commit" ,
162
+ env:: var( "SITE_URL" ) . expect( "SITE_URL defined" )
163
+ ) )
164
+ . send ( ) ?
165
+ . json ( ) ?;
166
+ let commit = if let Some ( c) = commit {
167
+ c
168
+ } else {
169
+ // no missing commits
170
+ return Ok ( ( ) ) ;
171
+ } ;
172
+
173
+ let commit = get_commit_or_fake_it ( & commit) ?;
174
+ match Sysroot :: install ( & commit. sha , commit. date . 0 , "x86_64-unknown-linux-gnu" ) {
175
+ Ok ( sysroot) => {
176
+ let result = out_repo. success ( & bench_commit (
177
+ Some ( & out_repo) ,
178
+ & commit,
179
+ & [ BuildKind :: Check , BuildKind :: Debug , BuildKind :: Opt ] ,
180
+ & RunKind :: all ( ) ,
181
+ Compiler :: from_sysroot ( & sysroot) ,
182
+ & benchmarks,
183
+ 3 ,
184
+ true ,
185
+ collect_self_profile,
186
+ ) ) ;
187
+ if let Err ( err) = result {
188
+ panic ! ( "failed to record success: {:?}" , err) ;
189
+ }
190
+ }
191
+ Err ( err) => {
192
+ error ! ( "failed to install sysroot for {:?}: {:?}" , commit, err) ;
193
+ }
194
+ }
195
+
196
+ Ok ( ( ) )
197
+ }
198
+
199
+ fn bench_published (
200
+ id : & str ,
201
+ repo : outrepo:: Repo ,
202
+ mut benchmarks : Vec < Benchmark > ,
203
+ ) -> Result < ( ) , Error > {
204
+ let commit = Commit {
205
+ sha : String :: from ( "<none>" ) ,
206
+ date : Date :: ymd_hms ( 2010 , 01 , 01 , 0 , 0 , 0 ) ,
207
+ } ;
208
+ let cfg = rustup:: Cfg :: from_env ( Arc :: new ( |_| { } ) ) . map_err ( SyncFailure :: new) ?;
209
+ let toolchain = rustup:: Toolchain :: from ( & cfg, id)
210
+ . map_err ( SyncFailure :: new)
211
+ . with_context ( |_| format ! ( "creating toolchain for id: {}" , id) ) ?;
212
+ toolchain
213
+ . install_from_dist_if_not_installed ( )
214
+ . map_err ( SyncFailure :: new) ?;
215
+
216
+ // Remove benchmarks that don't work with a stable compiler.
217
+ benchmarks. retain ( |b| b. supports_stable ( ) ) ;
218
+
219
+ let run_kinds = if collector:: version_supports_incremental ( id) {
220
+ RunKind :: all ( )
221
+ } else {
222
+ RunKind :: all_non_incr ( )
223
+ } ;
224
+ let CommitData {
225
+ benchmarks : benchmark_data,
226
+ ..
227
+ } = bench_commit (
228
+ None ,
229
+ & commit,
230
+ & [ BuildKind :: Check , BuildKind :: Debug , BuildKind :: Opt ] ,
231
+ & run_kinds,
232
+ Compiler {
233
+ rustc : & toolchain. binary_file ( "rustc" ) ,
234
+ cargo : & toolchain. binary_file ( "cargo" ) ,
235
+ is_nightly : false ,
236
+ triple : "x86_64-unknown-linux-gnu" ,
237
+ } ,
238
+ & benchmarks,
239
+ 3 ,
240
+ false ,
241
+ false ,
242
+ ) ;
243
+ repo. success_artifact ( & ArtifactData {
244
+ id : id. to_string ( ) ,
245
+ benchmarks : benchmark_data,
246
+ } ) ?;
247
+ Ok ( ( ) )
248
+ }
249
+
152
250
fn bench_commit (
153
251
repo : Option < & outrepo:: Repo > ,
154
252
commit : & Commit ,
@@ -358,7 +456,7 @@ fn main_result() -> Result<i32, Error> {
358
456
let benchmark_dir = PathBuf :: from ( "collector/benchmarks" ) ;
359
457
let filter = matches. value_of ( "filter" ) ;
360
458
let exclude = matches. value_of ( "exclude" ) ;
361
- let mut benchmarks = get_benchmarks ( & benchmark_dir, filter, exclude) ?;
459
+ let benchmarks = get_benchmarks ( & benchmark_dir, filter, exclude) ?;
362
460
let use_remote = matches. is_present ( "sync_git" ) ;
363
461
let collect_self_profile = matches. is_present ( "skip_self_profile" ) ;
364
462
@@ -436,93 +534,12 @@ fn main_result() -> Result<i32, Error> {
436
534
437
535
( "bench_published" , Some ( sub_m) ) => {
438
536
let id = sub_m. value_of ( "ID" ) . unwrap ( ) ;
439
- let repo = get_out_repo ( false ) ?;
440
- let commit = Commit {
441
- sha : String :: from ( "<none>" ) ,
442
- date : Date :: ymd_hms ( 2010 , 01 , 01 , 0 , 0 , 0 ) ,
443
- } ;
444
- let cfg = rustup:: Cfg :: from_env ( Arc :: new ( |_| { } ) ) . map_err ( SyncFailure :: new) ?;
445
- let toolchain = rustup:: Toolchain :: from ( & cfg, id)
446
- . map_err ( SyncFailure :: new)
447
- . with_context ( |_| format ! ( "creating toolchain for id: {}" , id) ) ?;
448
- toolchain
449
- . install_from_dist_if_not_installed ( )
450
- . map_err ( SyncFailure :: new) ?;
451
-
452
- // Remove benchmarks that don't work with a stable compiler.
453
- benchmarks. retain ( |b| b. supports_stable ( ) ) ;
454
-
455
- let run_kinds = if collector:: version_supports_incremental ( id) {
456
- RunKind :: all ( )
457
- } else {
458
- RunKind :: all_non_incr ( )
459
- } ;
460
- let CommitData {
461
- benchmarks : benchmark_data,
462
- ..
463
- } = bench_commit (
464
- None ,
465
- & commit,
466
- & [ BuildKind :: Check , BuildKind :: Debug , BuildKind :: Opt ] ,
467
- & run_kinds,
468
- Compiler {
469
- rustc : & toolchain. binary_file ( "rustc" ) ,
470
- cargo : & toolchain. binary_file ( "cargo" ) ,
471
- is_nightly : false ,
472
- triple : "x86_64-unknown-linux-gnu" ,
473
- } ,
474
- & benchmarks,
475
- 3 ,
476
- false ,
477
- false ,
478
- ) ;
479
- repo. success_artifact ( & ArtifactData {
480
- id : id. to_string ( ) ,
481
- benchmarks : benchmark_data,
482
- } ) ?;
537
+ bench_published ( & id, get_out_repo ( false ) ?, benchmarks) ?;
483
538
Ok ( 0 )
484
539
}
485
540
486
541
( "process" , Some ( _) ) => {
487
- let out_repo = get_out_repo ( false ) ?;
488
- println ! ( "processing commits" ) ;
489
- let client = reqwest:: Client :: new ( ) ;
490
- let commit: Option < String > = client
491
- . get ( & format ! (
492
- "{}/perf/next_commit" ,
493
- env:: var( "SITE_URL" ) . expect( "SITE_URL defined" )
494
- ) )
495
- . send ( ) ?
496
- . json ( ) ?;
497
- let commit = if let Some ( c) = commit {
498
- c
499
- } else {
500
- // no missing commits
501
- return Ok ( 0 ) ;
502
- } ;
503
-
504
- let commit = get_commit_or_fake_it ( & commit) ?;
505
- match Sysroot :: install ( & commit. sha , commit. date . 0 , "x86_64-unknown-linux-gnu" ) {
506
- Ok ( sysroot) => {
507
- let result = out_repo. success ( & bench_commit (
508
- Some ( & out_repo) ,
509
- & commit,
510
- & [ BuildKind :: Check , BuildKind :: Debug , BuildKind :: Opt ] ,
511
- & RunKind :: all ( ) ,
512
- Compiler :: from_sysroot ( & sysroot) ,
513
- & benchmarks,
514
- 3 ,
515
- true ,
516
- collect_self_profile,
517
- ) ) ;
518
- if let Err ( err) = result {
519
- panic ! ( "failed to record success: {:?}" , err) ;
520
- }
521
- }
522
- Err ( err) => {
523
- error ! ( "failed to install sysroot for {:?}: {:?}" , commit, err) ;
524
- }
525
- }
542
+ process_commits ( get_out_repo ( false ) ?, & benchmarks, collect_self_profile) ?;
526
543
Ok ( 0 )
527
544
}
528
545
0 commit comments