@@ -12,7 +12,11 @@ use crate::{
1212 archive,
1313 commands:: warn_user_about_loading_zip_in_memory,
1414 extension:: { split_first_compression_format, CompressionFormat :: * , Extension } ,
15- utils:: { io:: lock_and_flush_output_stdio, user_wants_to_continue, FileVisibilityPolicy } ,
15+ utils:: {
16+ io:: lock_and_flush_output_stdio,
17+ threads:: { logical_thread_count, physical_thread_count} ,
18+ user_wants_to_continue, FileVisibilityPolicy ,
19+ } ,
1620 QuestionAction , QuestionPolicy , BUFFER_CAPACITY ,
1721} ;
1822
@@ -52,6 +56,8 @@ pub fn compress_files(
5256 . compression_level (
5357 level. map_or_else ( Default :: default, |l| gzp:: Compression :: new ( ( l as u32 ) . clamp ( 0 , 9 ) ) ) ,
5458 )
59+ . num_threads ( logical_thread_count ( ) )
60+ . expect ( "gpz: num_threads must be greater than 0" )
5561 . from_writer ( encoder) ;
5662 parz
5763 } ) ,
@@ -84,7 +90,7 @@ pub fn compress_files(
8490 let dict_size = options. lzma_options . dict_size as u64 ;
8591 options. set_block_size ( NonZeroU64 :: new ( dict_size) ) ;
8692 // Use up to 256 PHYSICAL cores for compression
87- let writer = lzma_rust2:: XzWriterMt :: new ( encoder, options, num_cpus :: get_physical ( ) as u32 ) ?;
93+ let writer = lzma_rust2:: XzWriterMt :: new ( encoder, options, physical_thread_count ( ) as u32 ) ?;
8894 Box :: new ( writer. auto_finish ( ) )
8995 }
9096 Lzip => {
@@ -99,6 +105,8 @@ pub fn compress_files(
99105 . compression_level ( gzp:: par:: compress:: Compression :: new (
100106 level. map_or_else ( Default :: default, |l| ( l as u32 ) . clamp ( 0 , 9 ) ) ,
101107 ) )
108+ . num_threads ( logical_thread_count ( ) )
109+ . expect ( "gpz: num_threads must be greater than 0" )
102110 . from_writer ( encoder) ;
103111
104112 parz
@@ -111,7 +119,7 @@ pub fn compress_files(
111119 } ) ,
112120 ) ?;
113121 // Use all available PHYSICAL cores for compression
114- zstd_encoder. multithread ( num_cpus :: get_physical ( ) as u32 ) ?;
122+ zstd_encoder. multithread ( physical_thread_count ( ) as u32 ) ?;
115123 Box :: new ( zstd_encoder. auto_finish ( ) )
116124 }
117125 Brotli => {
0 commit comments