@@ -12,7 +12,6 @@ use std::env;
12
12
use std:: fmt;
13
13
use std:: fs:: { self , File } ;
14
14
use std:: hash;
15
- use std:: io:: Write as _;
16
15
use std:: path:: { Path , PathBuf } ;
17
16
use std:: process:: { self , Command , Stdio } ;
18
17
use std:: str;
@@ -21,34 +20,25 @@ use tempfile::TempDir;
21
20
use tokio:: runtime:: Runtime ;
22
21
23
22
fn to_s3 ( local : & Path , remote : & Path ) -> anyhow:: Result < ( ) > {
24
- let data = fs:: read ( local) . with_context ( || format ! ( "reading {:?}" , local) ) ?;
25
- let mut compressor = snap:: read:: FrameEncoder :: new ( & data[ ..] ) ;
26
- let mut compressed_file = tempfile:: NamedTempFile :: new ( ) . context ( "create temporary file" ) ?;
27
- {
28
- let mut buffered = std:: io:: BufWriter :: new ( & mut compressed_file) ;
29
- std:: io:: copy ( & mut compressor, & mut buffered) . context ( "compressed and written" ) ?;
30
- buffered. flush ( ) ?;
31
- }
32
-
33
23
let start = std:: time:: Instant :: now ( ) ;
34
24
let status = Command :: new ( "aws" )
35
25
. arg ( "s3" )
36
26
. arg ( "cp" )
37
27
. arg ( "--only-show-errors" )
38
- . arg ( compressed_file . path ( ) )
39
- . arg ( & format ! ( "s3://rustc-perf/{}.sz " , remote. to_str( ) . unwrap( ) ) )
28
+ . arg ( local )
29
+ . arg ( & format ! ( "s3://rustc-perf/{}" , remote. to_str( ) . unwrap( ) ) )
40
30
. status ( )
41
31
. with_context ( || {
42
32
format ! (
43
33
"upload {:?} to s3://rustc-perf/{}" ,
44
- compressed_file . path ( ) ,
34
+ local ,
45
35
remote. to_str( ) . unwrap( )
46
36
)
47
37
} ) ?;
48
38
if !status. success ( ) {
49
39
anyhow:: bail!(
50
40
"upload {:?} to s3://rustc-perf/{}: {:?}" ,
51
- compressed_file . path ( ) ,
41
+ local ,
52
42
remote. to_str( ) . unwrap( ) ,
53
43
status
54
44
) ;
@@ -637,13 +627,41 @@ impl<'a> MeasureProcessor<'a> {
637
627
. join ( self . krate . 0 . as_str ( ) )
638
628
. join ( profile. to_string ( ) )
639
629
. join ( cache. to_id ( ) ) ;
640
- let filename = |ext| format ! ( "self-profile-{}.{}" , collection, ext) ;
641
- to_s3 ( & files. string_index , & prefix. join ( filename ( "string_index" ) ) )
642
- . expect ( "s3 upload succeeded" ) ;
643
- to_s3 ( & files. string_data , & prefix. join ( filename ( "string_data" ) ) )
644
- . expect ( "s3 upload succeeded" ) ;
645
- to_s3 ( & files. events , & prefix. join ( filename ( "events" ) ) )
646
- . expect ( "s3 upload succeeded" ) ;
630
+ let tarball = snap:: write:: FrameEncoder :: new ( Vec :: new ( ) ) ;
631
+ let mut builder = tar:: Builder :: new ( tarball) ;
632
+ builder. mode ( tar:: HeaderMode :: Deterministic ) ;
633
+
634
+ let append_file = |builder : & mut tar:: Builder < _ > ,
635
+ file : & Path ,
636
+ name : & str |
637
+ -> anyhow:: Result < ( ) > {
638
+ builder. append_path_with_name ( file, name) ?;
639
+ Ok ( ( ) )
640
+ } ;
641
+ append_file ( & mut builder, & files. string_index , "string_index" )
642
+ . expect ( "append string index" ) ;
643
+ append_file ( & mut builder, & files. string_data , "string_data" )
644
+ . expect ( "append string data" ) ;
645
+ append_file ( & mut builder, & files. events , "events" ) . expect ( "append events" ) ;
646
+
647
+ let upload = tempfile:: NamedTempFile :: new ( )
648
+ . context ( "create temporary file" )
649
+ . unwrap ( ) ;
650
+ builder. finish ( ) . expect ( "complete tarball" ) ;
651
+ std:: fs:: write (
652
+ upload. path ( ) ,
653
+ builder
654
+ . into_inner ( )
655
+ . expect ( "get" )
656
+ . into_inner ( )
657
+ . expect ( "snap success" ) ,
658
+ )
659
+ . expect ( "wrote tarball" ) ;
660
+ to_s3 (
661
+ upload. path ( ) ,
662
+ & prefix. join ( format ! ( "self-profile-{}.tar.sz" , collection) ) ,
663
+ )
664
+ . expect ( "s3 upload succeeded" ) ;
647
665
648
666
self . rt . block_on ( self . conn . record_raw_self_profile (
649
667
collection,
0 commit comments