]> wimlib.net Git - wimlib/commitdiff
compress_parallel.c: Use 1 buffer per thread if chunks are big
authorEric Biggers <ebiggers3@gmail.com>
Thu, 2 Jan 2014 05:11:59 +0000 (23:11 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 2 Jan 2014 05:11:59 +0000 (23:11 -0600)
src/compress_parallel.c

index fa7f5dde113750adea8a1b43f12227748cd5109d..6cd306c2fcb96d5aa6d8b7e64c08c27022c3ff12 100644 (file)
@@ -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 *