@@ -89,43 +89,11 @@ impl CompressionFormat {
8989 xz2:: stream:: MtStreamBuilder :: new ( ) . threads ( 6 ) . preset ( 6 ) . encoder ( ) . unwrap ( )
9090 }
9191 CompressionProfile :: Best => {
92- let mut filters = xz2:: stream:: Filters :: new ( ) ;
93- // the preset is overridden by the other options so it doesn't matter
94- let mut lzma_ops = xz2:: stream:: LzmaOptions :: new_preset ( 9 ) . unwrap ( ) ;
95- // This sets the overall dictionary size, which is also how much memory (baseline)
96- // is needed for decompression.
97- lzma_ops. dict_size ( 64 * 1024 * 1024 ) ;
98- // Use the best match finder for compression ratio.
99- lzma_ops. match_finder ( xz2:: stream:: MatchFinder :: BinaryTree4 ) ;
100- lzma_ops. mode ( xz2:: stream:: Mode :: Normal ) ;
101- // Set nice len to the maximum for best compression ratio
102- lzma_ops. nice_len ( 273 ) ;
103- // Set depth to a reasonable value, 0 means auto, 1000 is somwhat high but gives
104- // good results.
105- lzma_ops. depth ( 1000 ) ;
106- // 2 is the default and does well for most files
107- lzma_ops. position_bits ( 2 ) ;
108- // 0 is the default and does well for most files
109- lzma_ops. literal_position_bits ( 0 ) ;
110- // 3 is the default and does well for most files
111- lzma_ops. literal_context_bits ( 3 ) ;
112-
113- filters. lzma2 ( & lzma_ops) ;
114-
115- let mut builder = xz2:: stream:: MtStreamBuilder :: new ( ) ;
116- builder. filters ( filters) ;
117-
118- // On 32-bit platforms limit ourselves to 3 threads, otherwise we exceed memory
119- // usage this process can take. In the future we'll likely only do super-fast
120- // compression in CI and move this heavyweight processing to promote-release (which
121- // is always 64-bit and can run on big-memory machines) but for now this lets us
122- // move forward.
123- if std:: mem:: size_of :: < usize > ( ) == 4 {
124- builder. threads ( 3 ) ;
125- } else {
126- builder. threads ( 6 ) ;
127- }
128- builder. encoder ( ) . unwrap ( )
92+ // Note that this isn't actually the best compression settings for the
93+ // produced artifacts, the production artifacts on static.rust-lang.org are
94+ // produced by rust-lang/promote-release which hosts recompression logic
95+ // and is tuned for optimal compression.
96+ xz2:: stream:: MtStreamBuilder :: new ( ) . threads ( 6 ) . preset ( 9 ) . encoder ( ) . unwrap ( )
12997 }
13098 } ;
13199
@@ -245,20 +213,14 @@ impl Write for CombinedEncoder {
245213 }
246214
247215 fn flush ( & mut self ) -> std:: io:: Result < ( ) > {
248- self . encoders
249- . par_iter_mut ( )
250- . map ( |w| w. flush ( ) )
251- . collect :: < std:: io:: Result < Vec < ( ) > > > ( ) ?;
216+ self . encoders . par_iter_mut ( ) . map ( |w| w. flush ( ) ) . collect :: < std:: io:: Result < Vec < ( ) > > > ( ) ?;
252217 Ok ( ( ) )
253218 }
254219}
255220
256221impl Encoder for CombinedEncoder {
257222 fn finish ( self : Box < Self > ) -> Result < ( ) , Error > {
258- self . encoders
259- . into_par_iter ( )
260- . map ( |e| e. finish ( ) )
261- . collect :: < Result < Vec < ( ) > , Error > > ( ) ?;
223+ self . encoders . into_par_iter ( ) . map ( |e| e. finish ( ) ) . collect :: < Result < Vec < ( ) > , Error > > ( ) ?;
262224 Ok ( ( ) )
263225 }
264226}
0 commit comments