From 44b239c501762cbee4ac0d218b144c937e642098 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 1 Jan 2014 23:11:59 -0600 Subject: [PATCH] compress_parallel.c: Use 1 buffer per thread if chunks are big --- src/compress_parallel.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compress_parallel.c b/src/compress_parallel.c index fa7f5dde..6cd306c2 100644 --- a/src/compress_parallel.c +++ b/src/compress_parallel.c @@ -423,8 +423,15 @@ new_parallel_chunk_compressor(int out_ctype, u32 out_chunk_size, desired_num_threads = num_threads; - chunks_per_msg = MAX_CHUNKS_PER_MSG; - msgs_per_thread = 2; + if (out_chunk_size < ((u32)1 << 23)) { + chunks_per_msg = MAX_CHUNKS_PER_MSG; + msgs_per_thread = 2; + } else { + /* Big chunks: Just have one buffer per thread --- more would + * just waste memory. */ + chunks_per_msg = 1; + msgs_per_thread = 1; + } for (;;) { approx_mem_required = (u64)chunks_per_msg * -- 2.43.0