Add log_avg_msec option
By default, fio will note an entry in the bw/iops/lat logs for every
IO that is completed. This quickly eats up a lot of disk space
for long running jobs. By setting this option to eg 1000, fio will
average the results logged over 1 second instead. This reduces the
resolution of the log, but makes it more manageable.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/stat.c b/stat.c
index 2400cd7..7de2362 100644
--- a/stat.c
+++ b/stat.c
@@ -1128,6 +1128,9 @@
{
const int nr_samples = iolog->nr_samples;
+ if (!iolog->nr_samples)
+ iolog->avg_last = t;
+
if (iolog->nr_samples == iolog->max_samples) {
int new_size = sizeof(struct io_sample) * iolog->max_samples*2;
@@ -1146,10 +1149,42 @@
unsigned long val, enum fio_ddir ddir,
unsigned int bs)
{
+ unsigned long elapsed, this_window, mr, mw;
+
if (!ddir_rw(ddir))
return;
- __add_log_sample(iolog, val, ddir, bs, mtime_since_now(&td->epoch));
+ elapsed = mtime_since_now(&td->epoch);
+
+ /*
+ * If no time averaging, just add the log sample.
+ */
+ if (!iolog->avg_msec) {
+ __add_log_sample(iolog, val, ddir, bs, elapsed);
+ return;
+ }
+
+ /*
+ * Add the sample. If the time period has passed, then
+ * add that entry to the log and clear.
+ */
+ add_stat_sample(&iolog->avg_window[ddir], val);
+
+ this_window = elapsed - iolog->avg_last;
+ if (this_window < iolog->avg_msec)
+ return;
+
+ mr = iolog->avg_window[DDIR_READ].mean.u.f;
+ mw = iolog->avg_window[DDIR_WRITE].mean.u.f;
+
+ if (mr)
+ __add_log_sample(iolog, mr, DDIR_READ, 0, elapsed);
+ if (mw)
+ __add_log_sample(iolog, mw, DDIR_WRITE, 0, elapsed);
+
+ memset(&iolog->avg_window[DDIR_READ], 0, sizeof(struct io_stat));
+ memset(&iolog->avg_window[DDIR_WRITE], 0, sizeof(struct io_stat));
+ iolog->avg_last = elapsed;
}
void add_agg_sample(unsigned long val, enum fio_ddir ddir, unsigned int bs)