diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-05-22 11:29:50 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-05-22 11:29:50 +0300 |
commit | b0063023f8adb06ea735ec4af5c6f5b7bdb8e84d (patch) | |
tree | 7a875e927ad12b63bba7e3f56d3240ab7e691734 /src/xz/args.c | |
parent | Support special value "max" where xz and xzdec accept an integer. (diff) | |
download | xz-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 '')
-rw-r--r-- | src/xz/args.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/xz/args.c b/src/xz/args.c index 5a6d177b..f38397cf 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -114,13 +114,27 @@ parse_real(args_info *args, int argc, char **argv) break; // --memory - case 'M': - // On 32-bit systems, SIZE_MAX would make more sense - // than UINT64_MAX. But use UINT64_MAX still so that - // scripts that assume > 4 GiB values don't break. - hardware_memlimit_set(str_to_uint64( - "memory", optarg, 0, UINT64_MAX)); + case 'M': { + // Support specifying the limit as a percentage of + // installed physical RAM. + size_t len = strlen(optarg); + if (len > 0 && optarg[len - 1] == '%') { + optarg[len - 1] = '\0'; + hardware_memlimit_set_percentage( + str_to_uint64( + "memory%", optarg, 1, 100)); + } else { + // On 32-bit systems, SIZE_MAX would make more + // sense than UINT64_MAX. But use UINT64_MAX + // still so that scripts that assume > 4 GiB + // values don't break. + hardware_memlimit_set(str_to_uint64( + "memory", optarg, + 0, UINT64_MAX)); + } + break; + } // --suffix case 'S': @@ -129,7 +143,7 @@ parse_real(args_info *args, int argc, char **argv) case 'T': hardware_threadlimit_set(str_to_uint64( - "threads", optarg, 1, SIZE_MAX)); + "threads", optarg, 0, UINT32_MAX)); break; // --version |