util: pipe: speed up dumping dlogutil 19/198419/2
authorMaciej Slodczyk <m.slodczyk2@partner.samsung.com>
Thu, 24 Jan 2019 10:43:07 +0000 (11:43 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 24 Jan 2019 11:28:06 +0000 (12:28 +0100)
Dumping dlogutil is slow because of too small read buffer
in util and clogging write pipe in daemon. Increase their
size to make the log dump quick.

Change-Id: If254bc650fdad98f4681540da754494f4522085f
Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
src/logger/logger.c
src/logutil/fdi_pipe.c

index e7126f0..722e34e 100644 (file)
@@ -1104,7 +1104,7 @@ static int reader_init_for_logger(struct reader *reader, const char *buf_name, s
        return 0;
 }
 
-static int create_fifo_fds(struct logger *server, int fifo_id, int *write_fd, int *read_fd)
+static int create_fifo_fds(struct logger *server, int fifo_id, int *write_fd, int *read_fd, bool dump)
 {
        assert(write_fd);
        assert(read_fd);
@@ -1135,6 +1135,17 @@ static int create_fifo_fds(struct logger *server, int fifo_id, int *write_fd, in
                goto finish;
        }
 
+       /* Speed up dumping dlogutils by increasing their pipe size,
+        * as otherwise this pipe's size becomes a major bottleneck.
+        *
+        * Continuous connections don't really care if the initial
+        * burst of "historic" logs is slow and the following flow
+        * of logs is just fine with a small pipe. Meanwhile they
+        * live for a long time during which they would take away
+        * from the valuable total pipe size. */
+       if (dump)
+               fcntl(*write_fd, F_SETPIPE_SZ, 4*PIPE_REQUESTED_SIZE);
+
 finish:
        unlink(fifo_path);
        return ret;
@@ -1268,7 +1279,7 @@ static int parse_command_line(const char *cmdl, struct writer *wr, struct logger
                        goto cleanup;
        } else if (wr) {
                int write_fd = -1, read_fd = -1;
-               retval = create_fifo_fds(server, wr->fd_entity.fd, &write_fd, &read_fd);
+               retval = create_fifo_fds(server, wr->fd_entity.fd, &write_fd, &read_fd, reader->dumpcount);
                if (retval < 0)
                        goto cleanup;
 
index 3c714cc..9a39779 100644 (file)
@@ -25,7 +25,7 @@
 #include "fd_info.h"
 #include "fdi_pipe.h"
 
-#define RECEIVE_BUFFER_SIZE 16384 // How large (in bytes) pipe receiving buffer is.
+#define RECEIVE_BUFFER_SIZE 1024*1024 // How large (in bytes) pipe receiving buffer is.
 
 struct pipe_priv_data {
        size_t data_len;