]> git.itanic.dy.fi Git - rrdd/commitdiff
rrdtool: Reduce excess parallelism
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Thu, 12 Apr 2012 18:52:09 +0000 (21:52 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Thu, 12 Apr 2012 19:05:46 +0000 (22:05 +0300)
Right now all commands are run "as parallel as possible", up to the
point images are being drawn while the databases are still
updated. This leads to problems where the image drawing finishes
before databases are read, thus the image contains always the
information from the last update instead of current.

This patch modifies the behavior so that when the database is being
updated, the drawing does not beging before the update has
succeeded.

Furthermore, image drawings are not done fully parallel. If they were,
the temporary file would be always renamed before there was any chance
that the actual image rendering was finished. Instead, rename is
synchronized with the image drawing.

As a consequence total parallelism is greatly reduced. This obviously
slows down update and image drawing process greatly on machines that
have many CPUs, that would otherwise benefit greatly from being able
to all actions in parallel. The maximum number of parallel actions is
practically limited to the number of databases that are being operated
with. The correctness of the operations is however more important than
maximising parallelism.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
rrdtool.c

index cb2eb43d827a1f5156ae2df06c8b00be31fe4ca6..3e54edf1b3096ab7916f502bfc38abe5b8ccab11 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -32,6 +32,7 @@
 
 int rrdtool_draw_image(struct rrd_image *image)
 {
+       int pid;
        char cmd[] = RRDTOOL_CMD;
 //     char cmd[] = "echo";
        char *args[512], argstr[ARGSTR_LEN];
@@ -86,7 +87,8 @@ int rrdtool_draw_image(struct rrd_image *image)
 
        args[argcnt] = 0;
 
-       run(cmd, args);
+       pid = run(cmd, args);
+       harvest_zombies(pid);
 
        rename(tmpfile, image->image_filename);
 
@@ -156,6 +158,7 @@ static int sanitize_rrd_update_data(char *data)
 
 int rrdtool_update_data(struct rrd_database *rrd)
 {
+       int pid;
        char data[RRD_DATA_MAX_LEN + 2];
        char cmd[] = RRDTOOL_CMD;
 //     char cmd[] = "echo";
@@ -177,7 +180,8 @@ int rrdtool_update_data(struct rrd_database *rrd)
        if (rrd->parse) {
                rrd->parse(data + l, rrd->parser_data);
                sanitize_rrd_update_data(data + l);
-               run(cmd, cmdline);
+               pid = run(cmd, cmdline);
+               harvest_zombies(pid);
        }
 
        if (rrd->images)