iowatcher: spawn NPROCESSORS_ONLN for rsvg-convert-s
authorJeff Moyer <jmoyer@redhat.com>
Fri, 31 Aug 2018 20:01:34 +0000 (16:01 -0400)
committerJens Axboe <axboe@kernel.dk>
Fri, 31 Aug 2018 20:57:57 +0000 (14:57 -0600)
iowatcher currently always spawns 8 rsvg-convert processes, no matter
how many CPUs a system has.  I did some limited testing of different
numbers of rsvg-convert processes.  Here are the results:

8 processes:
real 4m2.194s
user 23m36.665s
sys 0m38.523s

20 processes:
real 2m28.935s
user 24m51.817s
sys 0m49.227s

40 processes:
real 2m28.150s
user 24m56.994s
sys 0m49.621s

Note that this is the time it takes for a full run of iowatcher -- I
didn't separate out just the rsvg-convert portion.

Given the above results, it seems like a reasonable thing to spawn one
rsvg-convert process per cpu.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
iowatcher/main.c

index 54325fbfde5298259901b3d952d7b1aa9fe7448a..4b9701371c495eae8187c287af5231fd3c0da51b 100644 (file)
@@ -1043,9 +1043,14 @@ static void system_check(const char *cmd)
 
 static void convert_movie_files(char *movie_dir)
 {
+       long nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+
+       if (nr_cpus < 0)
+               nr_cpus = 8;
+
        fprintf(stderr, "Converting svg files in %s\n", movie_dir);
-       snprintf(line, line_len, "find %s -name \\*.svg | xargs -I{} -n 1 -P 8 rsvg-convert -o {}.png {}",
-                movie_dir);
+       snprintf(line, line_len, "find %s -name \\*.svg | xargs -I{} -n 1 -P %ld rsvg-convert -o {}.png {}",
+                movie_dir, nr_cpus);
        system_check(line);
 }