Hi, Lasse Collin wrote:
> With compression, -T0 in 5.1.1alpha sets the number of threads to match > the number of CPU cores. If no memory usage limit has been set, it may > end up using more memory than there is RAM. Pushing the system to swap > with threading is silly, because the point of threading in xz is to > make it faster. So it might make sense to have some kind of default > soft limit that is used to limit the number of threads when automatic > number of threads is requested. How about something like this patch, to start? With it applied, I am happy using XZ_DEFAULTS='--no-adjust --threads=0 --memlimit=1080MiB (As the FIXME comment in coder_set_compression_settings() explains, it is a little silly to waste so much space bookkeeping in those cases where memory constraints are tight enough to only allow using one thread, but that's a story for another day.) --- src/xz/coder.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/xz/coder.c b/src/xz/coder.c index 41193a7..5382689 100644 --- a/src/xz/coder.c +++ b/src/xz/coder.c @@ -229,12 +229,6 @@ coder_set_compression_settings(void) if (memory_usage <= memory_limit) return; - // If --no-auto-adjust was used or we didn't find LZMA1 or - // LZMA2 as the last filter, give an error immediately. - // --format=raw implies --no-auto-adjust. - if (!opt_auto_adjust || opt_format == FORMAT_RAW) - memlimit_too_small(memory_usage); - assert(opt_mode == MODE_COMPRESS); #ifdef HAVE_PTHREAD @@ -269,6 +263,12 @@ coder_set_compression_settings(void) if (memory_usage <= memory_limit) return; + // If --no-auto-adjust was used or we didn't find LZMA1 or + // LZMA2 as the last filter, give an error immediately. + // --format=raw implies --no-auto-adjust. + if (!opt_auto_adjust || opt_format == FORMAT_RAW) + memlimit_too_small(memory_usage); + // Look for the last filter if it is LZMA2 or LZMA1, so we can make // it use less RAM. With other filters we don't know what to do. size_t i = 0; -- 1.7.8.rc3