From: Jens Axboe Date: Mon, 16 Jun 2014 20:42:05 +0000 (-0600) Subject: Add string condensing for the ETA output X-Git-Tag: fio-2.1.11~61 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=3e2e48a72851354f7d6d4da9fc83d4a6df20e955;ds=sidebyside Add string condensing for the ETA output 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 --- diff --git a/HOWTO b/HOWTO index 1c89d75f..cad175c6 100644 --- 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 7500082f..52c17282 100644 --- 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); }