From b0063023f8adb06ea735ec4af5c6f5b7bdb8e84d Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Fri, 22 May 2009 11:29:50 +0300 Subject: Make the default memory usage limit 40 % of RAM for both compressing and decompressing. This should be OK now that xz automatically scales down the compression settings if they would exceed the memory usage limit (earlier, the limit for compression was increased to 90 % because low limit broke scripts that used "xz -9" on systems with low RAM). Support spcifying the memory usage limit as a percentage of RAM (e.g. --memory=50%). Support --threads=0 to reset the thread limit to the default value (number of available CPU cores). Use UINT32_MAX instead of SIZE_MAX as the maximum in args.c. hardware.c was already expecting uint32_t value. Cleaned up the output of --help and --long-help. --- src/xz/process.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/xz/process.c') diff --git a/src/xz/process.c b/src/xz/process.c index 4e682d7d..7a3c4149 100644 --- a/src/xz/process.c +++ b/src/xz/process.c @@ -152,15 +152,12 @@ coder_set_compression_settings(void) // If using --format=raw, we can be decoding. The memusage function // also validates the filter chain and the options used for the // filters. + const uint64_t memory_limit = hardware_memlimit_get(); uint64_t memory_usage; - uint64_t memory_limit; - if (opt_mode == MODE_COMPRESS) { + if (opt_mode == MODE_COMPRESS) memory_usage = lzma_raw_encoder_memusage(filters); - memory_limit = hardware_memlimit_encoder(); - } else { + else memory_usage = lzma_raw_decoder_memusage(filters); - memory_limit = hardware_memlimit_decoder(); - } if (memory_usage == UINT64_MAX) message_fatal("Unsupported filter chain or filter options"); @@ -286,17 +283,17 @@ coder_init(void) switch (opt_format) { case FORMAT_AUTO: ret = lzma_auto_decoder(&strm, - hardware_memlimit_decoder(), flags); + hardware_memlimit_get(), flags); break; case FORMAT_XZ: ret = lzma_stream_decoder(&strm, - hardware_memlimit_decoder(), flags); + hardware_memlimit_get(), flags); break; case FORMAT_LZMA: ret = lzma_alone_decoder(&strm, - hardware_memlimit_decoder()); + hardware_memlimit_get()); break; case FORMAT_RAW: @@ -436,8 +433,7 @@ coder_run(file_pair *pair) // Figure out how much memory it would have // actually needed. uint64_t memusage = lzma_memusage(&strm); - uint64_t memlimit - = hardware_memlimit_decoder(); + uint64_t memlimit = hardware_memlimit_get(); // Round the memory limit down and usage up. // This way we don't display a ridiculous -- cgit v1.2.3