@@ -14,6 +14,89 @@ pub struct Archive {
14
14
path : String ,
15
15
}
16
16
17
+ fn write_all_archive < DB : ReadResults , W : ReportWriter > (
18
+ db : & DB ,
19
+ ex : & Experiment ,
20
+ crates : & [ Crate ] ,
21
+ dest : & W ,
22
+ config : & Config ,
23
+ ) -> Fallible < Archive > {
24
+ for i in 1 ..=RETRIES {
25
+ let mut all = TarBuilder :: new ( GzEncoder :: new ( Vec :: new ( ) , Compression :: default ( ) ) ) ;
26
+ for krate in crates {
27
+ if config. should_skip ( krate) {
28
+ continue ;
29
+ }
30
+
31
+ let res1 = db. load_test_result ( ex, & ex. toolchains [ 0 ] , krate) ?;
32
+ let res2 = db. load_test_result ( ex, & ex. toolchains [ 1 ] , krate) ?;
33
+ let comparison = compare ( config, krate, res1. as_ref ( ) , res2. as_ref ( ) ) ;
34
+
35
+ for tc in & ex. toolchains {
36
+ let log = db
37
+ . load_log ( ex, tc, krate)
38
+ . and_then ( |c| c. ok_or_else ( || err_msg ( "missing logs" ) ) )
39
+ . with_context ( |_| format ! ( "failed to read log of {} on {}" , krate, tc) ) ;
40
+
41
+ let log_bytes: EncodedLog = match log {
42
+ Ok ( l) => l,
43
+ Err ( e) => {
44
+ crate :: utils:: report_failure ( & e) ;
45
+ continue ;
46
+ }
47
+ } ;
48
+
49
+ let log_bytes = log_bytes. to_plain ( ) ?;
50
+ let log_bytes = log_bytes. as_slice ( ) ;
51
+
52
+ let path = format ! (
53
+ "{}/{}/{}.txt" ,
54
+ comparison,
55
+ krate. id( ) ,
56
+ tc. to_path_component( ) ,
57
+ ) ;
58
+
59
+ let mut header = TarHeader :: new_gnu ( ) ;
60
+ header. set_size ( log_bytes. len ( ) as u64 ) ;
61
+ header. set_mode ( 0o644 ) ;
62
+ header. set_cksum ( ) ;
63
+
64
+ all. append_data ( & mut header, & path, log_bytes) ?;
65
+ }
66
+ }
67
+
68
+ let data = all. into_inner ( ) ?. finish ( ) ?;
69
+ let len = data. len ( ) ;
70
+ match dest. write_bytes_once (
71
+ "logs-archives/all.tar.gz" ,
72
+ data,
73
+ & "application/gzip" . parse ( ) . unwrap ( ) ,
74
+ EncodingType :: Plain ,
75
+ ) {
76
+ Ok ( ( ) ) => break ,
77
+ Err ( e) => {
78
+ if i == RETRIES {
79
+ return Err ( e) ;
80
+ } else {
81
+ std:: thread:: sleep ( std:: time:: Duration :: from_secs ( 2 ) ) ;
82
+ warn ! (
83
+ "retry ({}/{}) writing logs-archives/all.tar.gz ({} bytes)" ,
84
+ i, RETRIES , len,
85
+ ) ;
86
+ continue ;
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ Ok ( Archive {
93
+ name : "All the crates" . to_string ( ) ,
94
+ path : "logs-archives/all.tar.gz" . to_string ( ) ,
95
+ } )
96
+ }
97
+
98
+ const RETRIES : usize = 4 ;
99
+
17
100
pub fn write_logs_archives < DB : ReadResults , W : ReportWriter > (
18
101
db : & DB ,
19
102
ex : & Experiment ,
@@ -22,9 +105,10 @@ pub fn write_logs_archives<DB: ReadResults, W: ReportWriter>(
22
105
config : & Config ,
23
106
) -> Fallible < Vec < Archive > > {
24
107
let mut archives = Vec :: new ( ) ;
25
- let mut all = TarBuilder :: new ( GzEncoder :: new ( Vec :: new ( ) , Compression :: default ( ) ) ) ;
26
108
let mut by_comparison = IndexMap :: new ( ) ;
27
109
110
+ archives. push ( write_all_archive ( db, ex, crates, dest, config) ?) ;
111
+
28
112
for krate in crates {
29
113
if config. should_skip ( krate) {
30
114
continue ;
@@ -63,7 +147,6 @@ pub fn write_logs_archives<DB: ReadResults, W: ReportWriter>(
63
147
header. set_mode ( 0o644 ) ;
64
148
header. set_cksum ( ) ;
65
149
66
- all. append_data ( & mut header, & path, log_bytes) ?;
67
150
by_comparison
68
151
. entry ( comparison)
69
152
. or_insert_with ( || {
@@ -73,19 +156,6 @@ pub fn write_logs_archives<DB: ReadResults, W: ReportWriter>(
73
156
}
74
157
}
75
158
76
- let data = all. into_inner ( ) ?. finish ( ) ?;
77
- dest. write_bytes (
78
- "logs-archives/all.tar.gz" ,
79
- data,
80
- & "application/gzip" . parse ( ) . unwrap ( ) ,
81
- EncodingType :: Plain ,
82
- ) ?;
83
-
84
- archives. push ( Archive {
85
- name : "All the crates" . to_string ( ) ,
86
- path : "logs-archives/all.tar.gz" . to_string ( ) ,
87
- } ) ;
88
-
89
159
for ( comparison, archive) in by_comparison. drain ( ..) {
90
160
let data = archive. into_inner ( ) ?. finish ( ) ?;
91
161
dest. write_bytes (
0 commit comments