1
- use std:: collections:: HashSet ;
1
+ use std:: collections:: { BTreeMap , HashSet } ;
2
2
use std:: io:: Read ;
3
3
use std:: sync:: Arc ;
4
4
use std:: time:: { Duration , Instant } ;
5
5
6
6
use bytes:: Buf ;
7
+ use database:: ArtifactIdNumber ;
7
8
use headers:: { ContentType , Header } ;
8
9
use hyper:: StatusCode ;
9
10
@@ -14,8 +15,6 @@ use crate::load::SiteCtxt;
14
15
use crate :: selector:: { self , Tag } ;
15
16
use crate :: server:: { Response , ResponseHeaders } ;
16
17
17
- use std:: collections:: BTreeMap ;
18
-
19
18
pub async fn handle_self_profile_processed_download (
20
19
body : self_profile_processed:: Request ,
21
20
ctxt : & SiteCtxt ,
@@ -246,12 +245,10 @@ fn get_self_profile_delta(
246
245
profile : & self_profile:: SelfProfile ,
247
246
base_profile : & Option < self_profile:: SelfProfile > ,
248
247
raw_data : Vec < u8 > ,
249
- base_raw_data : Vec < u8 > ,
248
+ base_raw_data : Option < Vec < u8 > > ,
250
249
) -> Option < self_profile:: SelfProfileDelta > {
251
- let base_profile = match base_profile. as_ref ( ) {
252
- Some ( bp) => bp,
253
- None => return None ,
254
- } ;
250
+ let base_profile = base_profile. as_ref ( ) ?;
251
+ let base_raw_data = base_raw_data?;
255
252
256
253
let totals = self_profile:: QueryDataDelta {
257
254
self_time : profile. totals . self_time as i64 - base_profile. totals . self_time as i64 ,
@@ -593,15 +590,15 @@ pub async fn handle_self_profile_raw(
593
590
}
594
591
595
592
pub async fn fetch_raw_self_profile_data (
596
- aid : & str ,
593
+ aid : ArtifactIdNumber ,
597
594
benchmark : & str ,
598
595
profile : & str ,
599
596
scenario : & str ,
600
597
cid : i32 ,
601
598
) -> Result < Vec < u8 > , Response > {
602
599
let url = format ! (
603
- "https://perf-data.rust-lang.org/self-profile/{}/{}/{}/{}/self-profile-{}" ,
604
- aid, benchmark, profile, scenario, cid,
600
+ "https://perf-data.rust-lang.org/self-profile/{}/{}/{}/{}/self-profile-{}.mm_profdata.sz " ,
601
+ aid. 0 , benchmark, profile, scenario, cid,
605
602
) ;
606
603
607
604
get_self_profile_raw_data ( & url) . await
@@ -690,50 +687,43 @@ pub async fn handle_self_profile(
690
687
. await ?;
691
688
assert_eq ! ( cpu_responses. len( ) , 1 , "all selectors are exact" ) ;
692
689
let mut cpu_response = cpu_responses. remove ( 0 ) . series ;
693
- let mut raw_data = Vec :: new ( ) ;
690
+ let mut raw_self_profile_data = Vec :: new ( ) ;
694
691
let conn = ctxt. conn ( ) . await ;
695
692
for commit in commits. iter ( ) {
696
- let aid = match commit {
697
- ArtifactId :: Commit ( c) => c. sha . as_str ( ) ,
698
- ArtifactId :: Tag ( t) => t. as_str ( ) ,
699
- } ;
700
693
let aids_and_cids = conn
701
694
. list_self_profile ( commit. clone ( ) , bench_name, profile, & body. run_name )
702
695
. await ;
703
- if let Some ( ( _ , cid) ) = aids_and_cids. first ( ) {
704
- match fetch_raw_self_profile_data ( aid, bench_name, profile, & body. run_name , * cid) . await
696
+ if let Some ( ( aid , cid) ) = aids_and_cids. first ( ) {
697
+ match fetch_raw_self_profile_data ( * aid, bench_name, profile, & body. run_name , * cid) . await
705
698
{
706
- Ok ( d) => raw_data. push ( d) ,
707
- Err ( _resp) => {
708
- eprintln ! ( "could not fetch raw self_profile data" ) ;
709
- }
699
+ Ok ( d) => raw_self_profile_data. push ( d) ,
700
+ Err ( _) => return Err ( format ! ( "could not fetch raw profile data" ) ) ,
710
701
} ;
711
702
}
712
703
}
713
- let raw_datum = raw_data. remove ( 0 ) ;
714
- let base_raw_datum = raw_data. remove ( 0 ) ;
704
+ let raw_data = raw_self_profile_data. remove ( 0 ) ;
715
705
let mut profile = get_self_profile_data (
716
706
cpu_response. next ( ) . unwrap ( ) . 1 ,
717
707
sp_response. next ( ) . unwrap ( ) . 1 ,
718
- raw_datum . clone ( ) ,
708
+ raw_data . clone ( ) ,
719
709
)
720
710
. map_err ( |e| format ! ( "{}: {}" , body. commit, e) ) ?;
721
- let base_profile = if body. base_commit . is_some ( ) {
722
- Some (
723
- get_self_profile_data (
724
- cpu_response. next ( ) . unwrap ( ) . 1 ,
725
- sp_response. next ( ) . unwrap ( ) . 1 ,
726
- base_raw_datum. clone ( ) ,
727
- )
728
- . map_err ( |e| format ! ( "{}: {}" , body. base_commit. as_ref( ) . unwrap( ) , e) ) ?,
711
+ let ( base_profile, base_raw_data) = if body. base_commit . is_some ( ) {
712
+ let base_raw_data = raw_self_profile_data. remove ( 0 ) ;
713
+ let profile = get_self_profile_data (
714
+ cpu_response. next ( ) . unwrap ( ) . 1 ,
715
+ sp_response. next ( ) . unwrap ( ) . 1 ,
716
+ base_raw_data. clone ( ) ,
729
717
)
718
+ . map_err ( |e| format ! ( "{}: {}" , body. base_commit. as_ref( ) . unwrap( ) , e) ) ?;
719
+ ( Some ( profile) , Some ( base_raw_data) )
730
720
} else {
731
- None
721
+ ( None , None )
732
722
} ;
733
723
734
724
add_uninvoked_base_profile_queries ( & mut profile, & base_profile) ;
735
725
let mut base_profile_delta =
736
- get_self_profile_delta ( & profile, & base_profile, raw_datum , base_raw_datum ) ;
726
+ get_self_profile_delta ( & profile, & base_profile, raw_data , base_raw_data ) ;
737
727
sort_self_profile ( & mut profile, & mut base_profile_delta, sort_idx) ;
738
728
739
729
Ok ( self_profile:: Response {
0 commit comments