+ if (out_chunk_size < ((u32)1 << 23)) {
+ /* Relatively small chunks. Use 2 messages per thread, each
+ * with at least 2 chunks. Use more chunks per message if there
+ * are lots of threads and/or the chunks are very small. */
+ chunks_per_msg = 2;
+ chunks_per_msg += num_threads * (65536 / out_chunk_size) / 16;
+ chunks_per_msg = max(chunks_per_msg, 2);
+ chunks_per_msg = min(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;
+ }