@@ -1681,7 +1681,12 @@ fn run_benchmarks(
1681
1681
1682
1682
// Compile benchmarks
1683
1683
let compile_result = if let Some ( compile) = compile {
1684
- let errors = bench_compile ( rt, connection. as_mut ( ) , & shared, compile, & collector) ;
1684
+ let errors = rt. block_on ( bench_compile (
1685
+ connection. as_mut ( ) ,
1686
+ & shared,
1687
+ compile,
1688
+ & collector,
1689
+ ) ) ;
1685
1690
errors
1686
1691
. fail_if_nonzero ( )
1687
1692
. context ( "Compile benchmarks failed" )
@@ -1781,8 +1786,7 @@ async fn with_timeout<F: Future<Output = anyhow::Result<()>>>(fut: F) -> anyhow:
1781
1786
}
1782
1787
1783
1788
/// Perform compile benchmarks.
1784
- fn bench_compile (
1785
- rt : & mut Runtime ,
1789
+ async fn bench_compile (
1786
1790
conn : & mut dyn Connection ,
1787
1791
shared : & SharedBenchmarkConfig ,
1788
1792
config : CompileBenchmarkConfig ,
@@ -1798,51 +1802,62 @@ fn bench_compile(
1798
1802
1799
1803
let start = Instant :: now ( ) ;
1800
1804
1801
- let mut measure_and_record =
1802
- |benchmark_name : & BenchmarkName ,
1803
- category : Category ,
1804
- print_intro : & dyn Fn ( ) ,
1805
- measure : & dyn Fn ( & mut BenchProcessor ) -> anyhow:: Result < ( ) > | {
1806
- let is_fresh = rt. block_on ( collector. start_compile_step ( conn, benchmark_name) ) ;
1807
- if !is_fresh {
1808
- eprintln ! ( "skipping {} -- already benchmarked" , benchmark_name) ;
1809
- return ;
1810
- }
1811
- let mut tx = rt. block_on ( conn. transaction ( ) ) ;
1812
- let ( supports_stable, category) = category. db_representation ( ) ;
1813
- rt. block_on ( tx. conn ( ) . record_compile_benchmark (
1814
- & benchmark_name. 0 ,
1815
- Some ( supports_stable) ,
1816
- category,
1817
- ) ) ;
1818
- print_intro ( ) ;
1819
- let mut processor = BenchProcessor :: new (
1820
- tx. conn ( ) ,
1821
- benchmark_name,
1822
- & shared. artifact_id ,
1823
- collector. artifact_row_id ,
1824
- config. is_self_profile ,
1805
+ async fn measure_and_record < F : AsyncFn ( & mut BenchProcessor ) -> anyhow:: Result < ( ) > > (
1806
+ collector : & CollectorCtx ,
1807
+ shared : & SharedBenchmarkConfig ,
1808
+ config : & CompileBenchmarkConfig ,
1809
+ errors : & mut BenchmarkErrors ,
1810
+ conn : & mut dyn Connection ,
1811
+ benchmark_name : & BenchmarkName ,
1812
+ category : Category ,
1813
+ print_intro : & dyn Fn ( ) ,
1814
+ measure : F ,
1815
+ ) {
1816
+ let is_fresh = collector. start_compile_step ( conn, benchmark_name) . await ;
1817
+ if !is_fresh {
1818
+ eprintln ! ( "skipping {} -- already benchmarked" , benchmark_name) ;
1819
+ return ;
1820
+ }
1821
+ let mut tx = conn. transaction ( ) . await ;
1822
+ let ( supports_stable, category) = category. db_representation ( ) ;
1823
+ tx. conn ( )
1824
+ . record_compile_benchmark ( & benchmark_name. 0 , Some ( supports_stable) , category)
1825
+ . await ;
1826
+ print_intro ( ) ;
1827
+ let mut processor = BenchProcessor :: new (
1828
+ tx. conn ( ) ,
1829
+ benchmark_name,
1830
+ & shared. artifact_id ,
1831
+ collector. artifact_row_id ,
1832
+ config. is_self_profile ,
1833
+ ) ;
1834
+ let result = measure ( & mut processor) . await ;
1835
+ if let Err ( s) = result {
1836
+ eprintln ! (
1837
+ "collector error: Failed to benchmark '{}', recorded: {:#}" ,
1838
+ benchmark_name, s
1825
1839
) ;
1826
- let result = measure ( & mut processor) ;
1827
- if let Err ( s) = result {
1828
- eprintln ! (
1829
- "collector error: Failed to benchmark '{}', recorded: {:#}" ,
1830
- benchmark_name, s
1831
- ) ;
1832
- errors. incr ( ) ;
1833
- rt. block_on ( tx. conn ( ) . record_error (
1840
+ errors. incr ( ) ;
1841
+ tx. conn ( )
1842
+ . record_error (
1834
1843
collector. artifact_row_id ,
1835
1844
& benchmark_name. 0 ,
1836
1845
& format ! ( "{:?}" , s) ,
1837
- ) ) ;
1838
- } ;
1839
- rt. block_on ( collector. end_compile_step ( tx. conn ( ) , benchmark_name) ) ;
1840
- rt. block_on ( tx. commit ( ) ) . expect ( "committed" ) ;
1846
+ )
1847
+ . await ;
1841
1848
} ;
1849
+ collector. end_compile_step ( tx. conn ( ) , benchmark_name) . await ;
1850
+ tx. commit ( ) . await . expect ( "committed" ) ;
1851
+ }
1842
1852
1843
1853
// Normal benchmarks.
1844
1854
for ( nth_benchmark, benchmark) in config. benchmarks . iter ( ) . enumerate ( ) {
1845
1855
measure_and_record (
1856
+ collector,
1857
+ shared,
1858
+ & config,
1859
+ & mut errors,
1860
+ conn,
1846
1861
& benchmark. name ,
1847
1862
benchmark. category ( ) ,
1848
1863
& || {
@@ -1851,32 +1866,41 @@ fn bench_compile(
1851
1866
n_normal_benchmarks_remaining( config. benchmarks. len( ) - nth_benchmark)
1852
1867
)
1853
1868
} ,
1854
- & |processor| {
1855
- rt . block_on ( with_timeout ( benchmark. measure (
1869
+ async |processor| {
1870
+ with_timeout ( benchmark. measure (
1856
1871
processor,
1857
1872
& config. profiles ,
1858
1873
& config. scenarios ,
1859
1874
& config. backends ,
1860
1875
& shared. toolchain ,
1861
1876
config. iterations ,
1862
1877
& config. targets ,
1863
- ) ) )
1878
+ ) )
1879
+ . await
1864
1880
. with_context ( || anyhow:: anyhow!( "Cannot compile {}" , benchmark. name) )
1865
1881
} ,
1866
1882
)
1883
+ . await ;
1867
1884
}
1868
1885
1869
1886
// The special rustc benchmark, if requested.
1870
1887
if bench_rustc {
1871
1888
measure_and_record (
1889
+ collector,
1890
+ shared,
1891
+ & config,
1892
+ & mut errors,
1893
+ conn,
1872
1894
& BenchmarkName ( "rustc" . to_string ( ) ) ,
1873
1895
Category :: Primary ,
1874
1896
& || eprintln ! ( "Special benchmark commencing (due to `--bench-rustc`)" ) ,
1875
- & |processor| {
1876
- rt. block_on ( with_timeout ( processor. measure_rustc ( & shared. toolchain ) ) )
1897
+ async |processor| {
1898
+ with_timeout ( processor. measure_rustc ( & shared. toolchain ) )
1899
+ . await
1877
1900
. context ( "measure rustc" )
1878
1901
} ,
1879
- ) ;
1902
+ )
1903
+ . await ;
1880
1904
}
1881
1905
1882
1906
let end = start. elapsed ( ) ;
@@ -1886,10 +1910,8 @@ fn bench_compile(
1886
1910
end, errors. 0
1887
1911
) ;
1888
1912
1889
- rt. block_on ( async move {
1890
- // This ensures that we're good to go with the just updated data.
1891
- conn. maybe_create_indices ( ) . await ;
1892
- } ) ;
1913
+ // This ensures that we're good to go with the just updated data.
1914
+ conn. maybe_create_indices ( ) . await ;
1893
1915
errors
1894
1916
}
1895
1917
0 commit comments