@@ -151,23 +151,23 @@ impl<P: Deref<Target = Path>> DirectoryPackage<P> {
151151}
152152
153153// Probably this should live in diskio but ¯\_(ツ)_/¯
154- fn unpack_ram (
155- io_chunk_size : usize ,
156- effective_max_ram : Option < usize > ,
157- budget : Option < usize > ,
158- ) -> usize {
154+ fn unpack_ram ( io_chunk_size : usize , budget : Option < usize > ) -> usize {
159155 const RAM_ALLOWANCE_FOR_RUSTUP_AND_BUFFERS : usize = 200 * 1024 * 1024 ;
160156 let minimum_ram = io_chunk_size * 2 ;
161- let default_max_unpack_ram = if let Some ( effective_max_ram) = effective_max_ram {
162- if effective_max_ram > minimum_ram + RAM_ALLOWANCE_FOR_RUSTUP_AND_BUFFERS {
163- effective_max_ram - RAM_ALLOWANCE_FOR_RUSTUP_AND_BUFFERS
164- } else {
157+
158+ let default_max_unpack_ram = match effective_limits:: memory_limit ( ) {
159+ Ok ( effective)
160+ if effective as usize > minimum_ram + RAM_ALLOWANCE_FOR_RUSTUP_AND_BUFFERS =>
161+ {
162+ effective as usize - RAM_ALLOWANCE_FOR_RUSTUP_AND_BUFFERS
163+ }
164+ Ok ( _) => minimum_ram,
165+ Err ( error) => {
166+ error ! ( "can't determine memory limit: {error}" ) ;
165167 minimum_ram
166168 }
167- } else {
168- // Rustup does not know how much RAM the machine has: use the minimum
169- minimum_ram
170169 } ;
170+
171171 let unpack_ram = match budget {
172172 Some ( budget) => {
173173 if budget < minimum_ram {
@@ -279,14 +279,7 @@ fn unpack_without_first_dir<R: Read>(
279279 io_thread_count : usize ,
280280) -> Result < ( ) > {
281281 let entries = archive. entries ( ) ?;
282- let effective_max_ram = match effective_limits:: memory_limit ( ) {
283- Ok ( ram) => Some ( ram as usize ) ,
284- Err ( error) => {
285- error ! ( "can't determine memory limit: {error}" ) ;
286- None
287- }
288- } ;
289- let unpack_ram = unpack_ram ( IO_CHUNK_SIZE , effective_max_ram, unpack_ram_budget) ;
282+ let unpack_ram = unpack_ram ( IO_CHUNK_SIZE , unpack_ram_budget) ;
290283 let mut io_executor = get_executor ( unpack_ram, io_thread_count) ;
291284
292285 let mut directories: HashMap < PathBuf , DirStatus > = HashMap :: new ( ) ;
0 commit comments