From: Jens Axboe Date: Fri, 30 Nov 2018 17:52:31 +0000 (-0700) Subject: stat: only apply proper stat summing for event timestamps X-Git-Tag: fio-3.13~93 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=70750d6a221f2f9c160f52644e51784553720f8a;p=fio.git stat: only apply proper stat summing for event timestamps We generally sum two kinds of stats, one that is per-io type numbers, and one that are just samples of performance (like iops, bw). Only apply proper stat summing to the former, for the latter we just want to add them up. This fixes a group reporting case where we have multiple jobs, and the IOPS/BW output still shows per-job numbers. Before, we'd have: read: IOPS=345k, BW=1346MiB/s (1411MB/s)(6229MiB/4628msec) [...] bw ( KiB/s): min=282816, max=377080, per=24.99%, avg=344438.00, stdev=35329.77, samples=36 iops : min=70704, max=94270, avg=86109.50, stdev=8832.44, samples=36 with bw/iops showing per-job numbers, after this the same looks like: read: IOPS=349k, BW=1365MiB/s (1431MB/s)(6719MiB/4922msec) [...] bw ( MiB/s): min= 1302, max= 1420, per=99.86%, avg=1363.02, stdev=11.14, samples=36 iops : min=333433, max=363668, avg=348933.33, stdev=2850.64, samples=36 which is more in line with what a user would expect. Fixes: https://github.com/axboe/fio/issues/519 Signed-off-by: Jens Axboe --- diff --git a/stat.c b/stat.c index 331abf67..10625c49 100644 --- a/stat.c +++ b/stat.c @@ -1518,13 +1518,10 @@ struct json_object *show_thread_status(struct thread_stat *ts, return ret; } -static void sum_stat(struct io_stat *dst, struct io_stat *src, bool first) +static void __sum_stat(struct io_stat *dst, struct io_stat *src, bool first) { double mean, S; - if (src->samples == 0) - return; - dst->min_val = min(dst->min_val, src->min_val); dst->max_val = max(dst->max_val, src->max_val); @@ -1551,6 +1548,31 @@ static void sum_stat(struct io_stat *dst, struct io_stat *src, bool first) dst->samples += src->samples; dst->mean.u.f = mean; dst->S.u.f = S; + +} + +/* + * We sum two kinds of stats - one that is time based, in which case we + * apply the proper summing technique, and then one that is iops/bw + * numbers. For group_reporting, we should just add those up, not make + * them the mean of everything. + */ +static void sum_stat(struct io_stat *dst, struct io_stat *src, bool first, + bool pure_sum) +{ + if (src->samples == 0) + return; + + if (!pure_sum) { + __sum_stat(dst, src, first); + return; + } + + dst->min_val += src->min_val; + dst->max_val += src->max_val; + dst->samples += src->samples; + dst->mean.u.f += src->mean.u.f; + dst->S.u.f += src->S.u.f; } void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src) @@ -1586,22 +1608,22 @@ void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, for (l = 0; l < DDIR_RWDIR_CNT; l++) { if (!dst->unified_rw_rep) { - sum_stat(&dst->clat_stat[l], &src->clat_stat[l], first); - sum_stat(&dst->slat_stat[l], &src->slat_stat[l], first); - sum_stat(&dst->lat_stat[l], &src->lat_stat[l], first); - sum_stat(&dst->bw_stat[l], &src->bw_stat[l], first); - sum_stat(&dst->iops_stat[l], &src->iops_stat[l], first); + sum_stat(&dst->clat_stat[l], &src->clat_stat[l], first, false); + sum_stat(&dst->slat_stat[l], &src->slat_stat[l], first, false); + sum_stat(&dst->lat_stat[l], &src->lat_stat[l], first, false); + sum_stat(&dst->bw_stat[l], &src->bw_stat[l], first, true); + sum_stat(&dst->iops_stat[l], &src->iops_stat[l], first, true); dst->io_bytes[l] += src->io_bytes[l]; if (dst->runtime[l] < src->runtime[l]) dst->runtime[l] = src->runtime[l]; } else { - sum_stat(&dst->clat_stat[0], &src->clat_stat[l], first); - sum_stat(&dst->slat_stat[0], &src->slat_stat[l], first); - sum_stat(&dst->lat_stat[0], &src->lat_stat[l], first); - sum_stat(&dst->bw_stat[0], &src->bw_stat[l], first); - sum_stat(&dst->iops_stat[0], &src->iops_stat[l], first); + sum_stat(&dst->clat_stat[0], &src->clat_stat[l], first, false); + sum_stat(&dst->slat_stat[0], &src->slat_stat[l], first, false); + sum_stat(&dst->lat_stat[0], &src->lat_stat[l], first, false); + sum_stat(&dst->bw_stat[0], &src->bw_stat[l], first, true); + sum_stat(&dst->iops_stat[0], &src->iops_stat[l], first, true); dst->io_bytes[0] += src->io_bytes[l]; @@ -1616,7 +1638,7 @@ void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, } } - sum_stat(&dst->sync_stat, &src->sync_stat, first); + sum_stat(&dst->sync_stat, &src->sync_stat, first, false); dst->usr_time += src->usr_time; dst->sys_time += src->sys_time; dst->ctx += src->ctx;