aboutsummaryrefslogtreecommitdiff
path: root/src/xz/process.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-05-22 11:29:50 +0300
committerLasse Collin <lasse.collin@tukaani.org>2009-05-22 11:29:50 +0300
commitb0063023f8adb06ea735ec4af5c6f5b7bdb8e84d (patch)
tree7a875e927ad12b63bba7e3f56d3240ab7e691734 /src/xz/process.c
parentSupport special value "max" where xz and xzdec accept an integer. (diff)
downloadxz-b0063023f8adb06ea735ec4af5c6f5b7bdb8e84d.tar.xz
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.
Diffstat (limited to 'src/xz/process.c')
-rw-r--r--src/xz/process.c18
1 files changed, 7 insertions, 11 deletions
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