@@ -10,7 +10,7 @@ use collector::compile::benchmark::scenario::Scenario;
10
10
use collector:: compile:: benchmark:: {
11
11
compile_benchmark_dir, get_compile_benchmarks, ArtifactType , Benchmark , BenchmarkName ,
12
12
} ;
13
- use collector:: { runtime , utils, CollectorCtx , CollectorStepBuilder } ;
13
+ use collector:: { utils, CollectorCtx , CollectorStepBuilder } ;
14
14
use database:: { ArtifactId , ArtifactIdNumber , Commit , CommitType , Connection , Pool } ;
15
15
use rayon:: iter:: { IndexedParallelIterator , IntoParallelRefIterator , ParallelIterator } ;
16
16
use std:: cmp:: Ordering ;
@@ -31,9 +31,11 @@ use tokio::runtime::Runtime;
31
31
use collector:: compile:: execute:: bencher:: BenchProcessor ;
32
32
use collector:: compile:: execute:: profiler:: { ProfileProcessor , Profiler } ;
33
33
use collector:: runtime:: {
34
- bench_runtime, runtime_benchmark_dir, BenchmarkFilter , BenchmarkSuite ,
35
- BenchmarkSuiteCompilation , CargoIsolationMode , DEFAULT_RUNTIME_ITERATIONS ,
34
+ bench_runtime, prepare_runtime_benchmark_suite, runtime_benchmark_dir, BenchmarkFilter ,
35
+ BenchmarkSuite , BenchmarkSuiteCompilation , CargoIsolationMode , RuntimeProfiler ,
36
+ DEFAULT_RUNTIME_ITERATIONS ,
36
37
} ;
38
+ use collector:: runtime:: { profile_runtime, RuntimeCompilationOpts } ;
37
39
use collector:: toolchain:: {
38
40
create_toolchain_from_published_version, get_local_toolchain, Sysroot , Toolchain ,
39
41
} ;
@@ -255,7 +257,7 @@ fn cg_annotate(cgout: &Path, path: &Path) -> anyhow::Result<()> {
255
257
}
256
258
257
259
#[ allow( clippy:: too_many_arguments) ]
258
- fn profile (
260
+ fn profile_compile (
259
261
toolchain : & Toolchain ,
260
262
profiler : Profiler ,
261
263
out_dir : & Path ,
@@ -502,6 +504,19 @@ enum Commands {
502
504
#[ arg( long = "no-isolate" ) ]
503
505
no_isolate : bool ,
504
506
} ,
507
+
508
+ /// Profiles a runtime benchmark.
509
+ ProfileRuntime {
510
+ /// Profiler to use
511
+ profiler : RuntimeProfiler ,
512
+
513
+ /// The path to the local rustc used to compile the runtime benchmark
514
+ rustc : String ,
515
+
516
+ /// Name of the benchmark that should be profiled
517
+ benchmark : String ,
518
+ } ,
519
+
505
520
/// Benchmarks a local rustc
506
521
BenchLocal {
507
522
#[ command( flatten) ]
@@ -650,15 +665,7 @@ fn main_result() -> anyhow::Result<i32> {
650
665
no_isolate,
651
666
} => {
652
667
log_db ( & db) ;
653
- let toolchain = get_local_toolchain (
654
- & [ Profile :: Opt ] ,
655
- & local. rustc ,
656
- None ,
657
- local. cargo . as_deref ( ) ,
658
- local. id . as_deref ( ) ,
659
- "" ,
660
- target_triple,
661
- ) ?;
668
+ let toolchain = get_local_toolchain_for_runtime_benchmarks ( & local, & target_triple) ?;
662
669
let pool = Pool :: open ( & db. db ) ;
663
670
664
671
let isolation_mode = if no_isolate {
@@ -689,6 +696,25 @@ fn main_result() -> anyhow::Result<i32> {
689
696
run_benchmarks ( & mut rt, conn, shared, None , Some ( config) ) ?;
690
697
Ok ( 0 )
691
698
}
699
+ Commands :: ProfileRuntime {
700
+ profiler,
701
+ rustc,
702
+ benchmark,
703
+ } => {
704
+ let toolchain =
705
+ get_local_toolchain ( & [ Profile :: Opt ] , & rustc, None , None , None , "" , target_triple) ?;
706
+ let suite = prepare_runtime_benchmark_suite (
707
+ & toolchain,
708
+ & runtime_benchmark_dir,
709
+ CargoIsolationMode :: Cached ,
710
+ // Compile with debuginfo to have filenames and line numbers available in the
711
+ // generated profiles.
712
+ RuntimeCompilationOpts :: default ( ) . debug_info ( "1" ) ,
713
+ ) ?
714
+ . suite ;
715
+ profile_runtime ( profiler, suite, & benchmark) ?;
716
+ Ok ( 0 )
717
+ }
692
718
Commands :: BenchLocal {
693
719
local,
694
720
opts,
@@ -904,7 +930,7 @@ fn main_result() -> anyhow::Result<i32> {
904
930
target_triple. clone ( ) ,
905
931
) ?;
906
932
let id = toolchain. id . clone ( ) ;
907
- profile (
933
+ profile_compile (
908
934
& toolchain,
909
935
profiler,
910
936
& out_dir,
@@ -1005,6 +1031,21 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
1005
1031
}
1006
1032
}
1007
1033
1034
+ fn get_local_toolchain_for_runtime_benchmarks (
1035
+ local : & LocalOptions ,
1036
+ target_triple : & str ,
1037
+ ) -> anyhow:: Result < Toolchain > {
1038
+ get_local_toolchain (
1039
+ & [ Profile :: Opt ] ,
1040
+ & local. rustc ,
1041
+ None ,
1042
+ local. cargo . as_deref ( ) ,
1043
+ local. id . as_deref ( ) ,
1044
+ "" ,
1045
+ target_triple. to_string ( ) ,
1046
+ )
1047
+ }
1048
+
1008
1049
async fn load_runtime_benchmarks (
1009
1050
conn : & mut dyn Connection ,
1010
1051
benchmark_dir : & Path ,
@@ -1015,7 +1056,12 @@ async fn load_runtime_benchmarks(
1015
1056
let BenchmarkSuiteCompilation {
1016
1057
suite,
1017
1058
failed_to_compile,
1018
- } = runtime:: prepare_runtime_benchmark_suite ( toolchain, benchmark_dir, isolation_mode) ?;
1059
+ } = prepare_runtime_benchmark_suite (
1060
+ toolchain,
1061
+ benchmark_dir,
1062
+ isolation_mode,
1063
+ RuntimeCompilationOpts :: default ( ) ,
1064
+ ) ?;
1019
1065
1020
1066
record_runtime_compilation_errors ( conn, artifact_id, failed_to_compile) . await ;
1021
1067
Ok ( suite)
0 commit comments