@@ -932,9 +932,9 @@ pub async fn handle_self_profile_raw_download(
932
932
body : self_profile_raw:: Request ,
933
933
data : & InputData ,
934
934
) -> Response {
935
- let res = handle_self_profile_raw ( body, data, false ) . await ;
936
- let url = match res {
937
- Ok ( v) => v. url ,
935
+ let res = handle_self_profile_raw ( body, data) . await ;
936
+ let ( url, is_tarball ) = match res {
937
+ Ok ( v) => ( v. url , v . is_tarball ) ,
938
938
Err ( e) => {
939
939
let mut resp = Response :: new ( e. into ( ) ) ;
940
940
* resp. status_mut ( ) = StatusCode :: BAD_REQUEST ;
@@ -969,7 +969,12 @@ pub async fn handle_self_profile_raw_download(
969
969
server_resp. headers_mut ( ) . insert (
970
970
hyper:: header:: CONTENT_DISPOSITION ,
971
971
hyper:: header:: HeaderValue :: from_maybe_shared ( format ! (
972
- "attachment; filename=\" self-profile.tar\" "
972
+ "attachment; filename=\" {}\" " ,
973
+ if is_tarball {
974
+ "self-profile.tar"
975
+ } else {
976
+ "self-profile.mm_profdata"
977
+ }
973
978
) )
974
979
. expect ( "valid header" ) ,
975
980
) ;
@@ -1071,7 +1076,6 @@ async fn tarball(resp: reqwest::Response, mut sender: hyper::body::Sender) {
1071
1076
pub async fn handle_self_profile_raw (
1072
1077
body : self_profile_raw:: Request ,
1073
1078
data : & InputData ,
1074
- validate : bool ,
1075
1079
) -> ServerResult < self_profile_raw:: Response > {
1076
1080
log:: info!( "handle_self_profile_raw({:?})" , body) ;
1077
1081
let mut it = body. benchmark . rsplitn ( 2 , '-' ) ;
@@ -1112,16 +1116,42 @@ pub async fn handle_self_profile_raw(
1112
1116
_ => first_cid,
1113
1117
} ;
1114
1118
1115
- let url = format ! (
1116
- "https://perf-data.rust-lang.org/self-profile/{}/{}/{}/{}/self-profile-{}.tar.sz " ,
1119
+ let url_prefix = format ! (
1120
+ "https://perf-data.rust-lang.org/self-profile/{}/{}/{}/{}/self-profile-{}" ,
1117
1121
aid. 0 ,
1118
1122
bench_name,
1119
1123
bench_ty,
1120
1124
cache. to_id( ) ,
1121
- cid
1125
+ cid,
1122
1126
) ;
1123
1127
1124
- if validate {
1128
+ let cids = aids_and_cids
1129
+ . into_iter ( )
1130
+ . map ( |( _, cid) | cid)
1131
+ . collect :: < Vec < _ > > ( ) ;
1132
+
1133
+ return match fetch ( & cids, cid, format ! ( "{}.mm_profdata.sz" , url_prefix) , false ) . await {
1134
+ Ok ( fetched) => Ok ( fetched) ,
1135
+ Err ( new_error) => {
1136
+ match fetch ( & cids, cid, format ! ( "{}.tar.sz" , url_prefix) , true ) . await {
1137
+ Ok ( fetched) => Ok ( fetched) ,
1138
+ Err ( old_error) => {
1139
+ // Both files failed to fetch; return the errors for both:
1140
+ Err ( format ! (
1141
+ "mm_profdata download failed: {:?}, tarball download failed: {:?}" ,
1142
+ new_error, old_error
1143
+ ) )
1144
+ }
1145
+ }
1146
+ }
1147
+ } ;
1148
+
1149
+ async fn fetch (
1150
+ cids : & [ i32 ] ,
1151
+ cid : i32 ,
1152
+ url : String ,
1153
+ is_tarball : bool ,
1154
+ ) -> ServerResult < self_profile_raw:: Response > {
1125
1155
let resp = reqwest:: Client :: new ( )
1126
1156
. head ( & url)
1127
1157
. send ( )
@@ -1133,13 +1163,14 @@ pub async fn handle_self_profile_raw(
1133
1163
resp. status( )
1134
1164
) ) ;
1135
1165
}
1136
- }
1137
1166
1138
- Ok ( self_profile_raw:: Response {
1139
- cids : aids_and_cids. into_iter ( ) . map ( |( _, cid) | cid) . collect ( ) ,
1140
- cid,
1141
- url,
1142
- } )
1167
+ Ok ( self_profile_raw:: Response {
1168
+ cids : cids. to_vec ( ) ,
1169
+ cid,
1170
+ url,
1171
+ is_tarball,
1172
+ } )
1173
+ }
1143
1174
}
1144
1175
1145
1176
pub async fn handle_self_profile (
@@ -1656,7 +1687,7 @@ async fn serve_req(ctx: Arc<Server>, req: Request) -> Result<Response, ServerErr
1656
1687
) )
1657
1688
} else if p == "/perf/self-profile-raw" {
1658
1689
Ok ( to_response (
1659
- handle_self_profile_raw ( body ! ( parse_body( & body) ) , & data, true ) . await ,
1690
+ handle_self_profile_raw ( body ! ( parse_body( & body) ) , & data) . await ,
1660
1691
) )
1661
1692
} else if p == "/perf/graph-new" {
1662
1693
Ok (
0 commit comments