Add string condensing for the ETA output
authorJens Axboe <axboe@fb.com>
Mon, 16 Jun 2014 20:42:05 +0000 (14:42 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 16 Jun 2014 20:42:05 +0000 (14:42 -0600)
If you run a lot of jobs, the ETA output string will become way too
long. Add some condensing so that instead of displaying:

Jobs: 80 (f=80): [rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr] [10.2% done] [2110MB/0KB/0KB /s] [540K/0/0 iops] [eta 53m:55s]

we just display

Jobs: 80 (f=80): [r(80)] [10.2% done] [2110MB/0KB/0KB /s] [540K/0/0 iops] [eta 53m:55s]

instead.

Signed-off-by: Jens Axboe <axboe@fb.com>
HOWTO
eta.c

diff --git a/HOWTO b/HOWTO
index 1c89d75f29cf6a01264d9f6dbbaaefc9b529a9e8..cad175c6fb59fed73407afe48ffc9cf43e6759f6 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -1607,6 +1607,15 @@ _                Thread reaped, or
 X              Thread reaped, exited with an error.
 K              Thread reaped, exited due to signal.
 
+Fio will condense the thread string as not to take up more space on the
+command line as is needed. For instance, if you have 10 readers and 10
+writers running, the output would look like this:
+
+Jobs: 20 (f=20): [R(10),W(10)] [4.0% done] [2103MB/0KB/0KB /s] [538K/0/0 iops] [eta 57m:36s]
+
+Fio will still maintain the ordering, though. So the above means that jobs
+1..10 are readers, and 11..20 are writers.
+
 The other values are fairly self explanatory - number of threads
 currently running and doing io, rate of io since last check (read speed
 listed first, then write speed), and the estimated completion percentage
diff --git a/eta.c b/eta.c
index 7500082f4e2398da125b8a1a01cc7e981a021222..52c17282e89ce53e96ac7c43bc64117003224814 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -7,14 +7,54 @@
 
 #include "fio.h"
 
-static char run_str[REAL_MAX_JOBS + 1];
+static char __run_str[REAL_MAX_JOBS + 1];
+
+/*
+ * Worst level condensing would be 1:4, so allow enough room for that
+ */
+static char run_str[(4 * REAL_MAX_JOBS) + 1];
+
+static void update_condensed_str(char *run_str, char *run_str_condensed)
+{
+       int i, ci, last, nr;
+       size_t len;
+
+       len = strlen(run_str);
+       if (!len)
+               return;
+
+       last = 0;
+       nr = 0;
+       ci = 0;
+       for (i = 0; i < len; i++) {
+               if (!last) {
+new:
+                       run_str_condensed[ci] = run_str[i];
+                       last = run_str[i];
+                       nr = 1;
+                       ci++;
+               } else if (last == run_str[i]) {
+                       nr++;
+               } else {
+                       int elen;
+
+                       elen = sprintf(&run_str_condensed[ci], "(%u),", nr);
+                       ci += elen;
+                       goto new;
+               }
+       }
+
+       if (nr)
+               sprintf(&run_str_condensed[ci], "(%u)", nr);
+}
+
 
 /*
  * Sets the status of the 'td' in the printed status map.
  */
 static void check_str_update(struct thread_data *td)
 {
-       char c = run_str[td->thread_number - 1];
+       char c = __run_str[td->thread_number - 1];
 
        switch (td->runstate) {
        case TD_REAPED:
@@ -91,7 +131,8 @@ static void check_str_update(struct thread_data *td)
                log_err("state %d\n", td->runstate);
        }
 
-       run_str[td->thread_number - 1] = c;
+       __run_str[td->thread_number - 1] = c;
+       update_condensed_str(__run_str, run_str);
 }
 
 /*
@@ -564,5 +605,6 @@ void print_thread_status(void)
 
 void print_status_init(int thr_number)
 {
-       run_str[thr_number] = 'P';
+       __run_str[thr_number] = 'P';
+       update_condensed_str(__run_str, run_str);
 }