diff --git a/ChangeLog b/ChangeLog index 09ed101..4898b68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,9 +6,8 @@ FEBRUARY 2011, version 0.561 Con Kolivas * Delete temporary files generated when testing from stdin. * Don't call perror on failures that aren't system related. * Improve visual output. -* Significant multi-threading speed-ups - Use one more thread than CPUs, and -use a smaller buffer on the first thread and slightly more each next thread -until the next stream. Then repeat the cycle. +* Significant multi-threading speed-ups - as the spawning of threads is +partially serialised, use one more thread than CPUs. * Don't split up the chunks into multiple threads when no back end compression is being used. * Take into account the precise amount of overhead that the memory hungry diff --git a/rzip.h b/rzip.h index 2ad5b5e..a95390b 100644 --- a/rzip.h +++ b/rzip.h @@ -301,7 +301,6 @@ struct stream_info { int num_streams; int fd; i64 bufsize; - i64 max_bufsize; i64 cur_pos; i64 initial_pos; i64 total_read; diff --git a/stream.c b/stream.c index 1c6a444..8384122 100644 --- a/stream.c +++ b/stream.c @@ -814,24 +814,14 @@ retest_malloc: free(testmalloc); print_maxverbose("Succeeded in testing %lld sized malloc for back end compression\n", testsize); - sinfo->max_bufsize = MIN(limit, - MAX((limit + control.threads - 1) / control.threads, - STREAM_BUFSIZE)); - sinfo->bufsize = sinfo->max_bufsize; + /* Make the bufsize no smaller than STREAM_BUFSIZE. Round up the + * bufsize to fit X threads into it */ + sinfo->bufsize = MIN(limit, MAX((limit + control.threads - 1) / control.threads, + STREAM_BUFSIZE)); - /* We start with slightly smaller buffers to start loading CPUs as soon - * as possible and make them exponentially larger approaching the - * tested maximum size. We ensure the buffers are of a minimum size, - * though, as compression efficency drops off dramatically with tiny - * buffers. */ - if (control.threads > 1 && sinfo->max_bufsize > STREAM_BUFSIZE) { - sinfo->bufsize = sinfo->max_bufsize * 63 / 100; - sinfo->bufsize = MAX(sinfo->bufsize, STREAM_BUFSIZE); - } - if (control.threads > 1) print_maxverbose("Using up to %d threads to compress up to %lld bytes each.\n", - control.threads, sinfo->max_bufsize); + control.threads, sinfo->bufsize); else print_maxverbose("Using only 1 thread to compress up to %lld bytes\n", sinfo->bufsize); @@ -1072,9 +1062,6 @@ static void clear_buffer(struct stream_info *sinfo, int stream, int newbuf) i, cthread[i].s_len, stream); create_pthread(&threads[i], NULL, compthread, (void *)i); - if (control.threads > 1) - sinfo->bufsize += (sinfo->max_bufsize - sinfo->bufsize) * 63 / 100; - if (newbuf) { /* The stream buffer has been given to the thread, allocate a new one */ sinfo->s[stream].buf = malloc(sinfo->bufsize);