ts->percentile_list);
}
if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
- double p_of_agg;
+ double p_of_agg = 100.0;
const char *bw_str = "KB";
- p_of_agg = mean * 100 / (double) rs->agg[ddir];
- if (p_of_agg > 100.0)
- p_of_agg = 100.0;
+ if (rs->agg[ddir]) {
+ p_of_agg = mean * 100 / (double) rs->agg[ddir];
+ if (p_of_agg > 100.0)
+ p_of_agg = 100.0;
+ }
if (mean > 999999.9) {
min /= 1000.0;
if (ts->runtime[ddir]) {
uint64_t runt = ts->runtime[ddir];
- bw = ts->io_bytes[ddir] / runt;
+ bw = ((1000 * ts->io_bytes[ddir]) / runt) / 1024;
iops = (1000 * (uint64_t) ts->total_io_u[ddir]) / runt;
}
free(ovals);
if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
- double p_of_agg;
+ double p_of_agg = 100.0;
+
+ if (rs->agg[ddir]) {
+ p_of_agg = mean * 100 / (double) rs->agg[ddir];
+ if (p_of_agg > 100.0)
+ p_of_agg = 100.0;
+ }
- p_of_agg = mean * 100 / (double) rs->agg[ddir];
log_info(";%lu;%lu;%f%%;%f;%f", min, max, p_of_agg, mean, dev);
} else
log_info(";%lu;%lu;%f%%;%f;%f", 0UL, 0UL, 0.0, 0.0, 0.0);
/* Additional output if continue_on_error set - default off*/
if (ts->continue_on_error)
log_info(";%lu;%d", ts->total_err_count, ts->first_error);
- log_info("\n");
/* Additional output if description is set */
if (strlen(ts->description))
log_info(";%s", ts->description);
+
+ log_info("\n");
}
static void show_thread_status_terse(struct thread_stat *ts,
bw = 0;
if (ts->runtime[j]) {
- unsigned long runt;
+ unsigned long runt = ts->runtime[j];
+ unsigned long long kb;
- runt = ts->runtime[j];
- bw = ts->io_bytes[j] / runt;
+ kb = ts->io_bytes[j] / rs->kb_base;
+ bw = kb * 1000 / runt;
}
if (bw < rs->min_bw[j])
rs->min_bw[j] = bw;
}
for (i = 0; i < groupid + 1; i++) {
- unsigned long max_run[2];
-
rs = &runstats[i];
- max_run[0] = rs->max_run[0];
- max_run[1] = rs->max_run[1];
if (rs->max_run[0])
- rs->agg[0] = (rs->io_kb[0] * 1000) / max_run[0];
+ rs->agg[0] = (rs->io_kb[0] * 1000) / rs->max_run[0];
if (rs->max_run[1])
- rs->agg[1] = (rs->io_kb[1] * 1000) / max_run[1];
+ rs->agg[1] = (rs->io_kb[1] * 1000) / rs->max_run[1];
}
/*
else if (!terse_output)
show_disk_util(0);
- free_disk_util();
-
free(runstats);
free(threadstats);
}
+static void *__show_running_run_stats(void *arg)
+{
+ struct thread_data *td;
+ unsigned long long *rt;
+ struct timeval tv;
+ int i;
+
+ rt = malloc(thread_number * sizeof(unsigned long long));
+ fio_gettime(&tv, NULL);
+
+ for_each_td(td, i) {
+ rt[i] = mtime_since(&td->start, &tv);
+ if (td_read(td) && td->io_bytes[DDIR_READ])
+ td->ts.runtime[DDIR_READ] += rt[i];
+ if (td_write(td) && td->io_bytes[DDIR_WRITE])
+ td->ts.runtime[DDIR_WRITE] += rt[i];
+
+ update_rusage_stat(td);
+ td->ts.io_bytes[0] = td->io_bytes[0];
+ td->ts.io_bytes[1] = td->io_bytes[1];
+ td->ts.total_run_time = mtime_since(&td->epoch, &tv);
+ }
+
+ show_run_stats();
+
+ for_each_td(td, i) {
+ if (td_read(td) && td->io_bytes[DDIR_READ])
+ td->ts.runtime[DDIR_READ] -= rt[i];
+ if (td_write(td) && td->io_bytes[DDIR_WRITE])
+ td->ts.runtime[DDIR_WRITE] -= rt[i];
+ }
+
+ free(rt);
+ return NULL;
+}
+
+/*
+ * Called from signal handler. It _should_ be safe to just run this inline
+ * in the sig handler, but we should be disturbing the system less by just
+ * creating a thread to do it.
+ */
+void show_running_run_stats(void)
+{
+ pthread_t thread;
+
+ pthread_create(&thread, NULL, __show_running_run_stats, NULL);
+ pthread_detach(thread);
+}
+
static inline void add_stat_sample(struct io_stat *is, unsigned long data)
{
double val = data;
iolog->nr_samples++;
}
+static inline void reset_io_stat(struct io_stat *ios)
+{
+ ios->max_val = ios->min_val = ios->samples = 0;
+ ios->mean.u.f = ios->S.u.f = 0;
+}
+
static void add_log_sample(struct thread_data *td, struct io_log *iolog,
unsigned long val, enum fio_ddir ddir,
unsigned int bs)
{
- unsigned long elapsed, this_window, mr, mw;
+ unsigned long elapsed, this_window;
if (!ddir_rw(ddir))
return;
*/
add_stat_sample(&iolog->avg_window[ddir], val);
+ /*
+ * If period hasn't passed, adding the above sample is all we
+ * need to do.
+ */
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;
+ /*
+ * Note an entry in the log. Use the mean from the logged samples,
+ * making sure to properly round up. Only write a log entry if we
+ * had actual samples done.
+ */
+ if (iolog->avg_window[DDIR_READ].samples) {
+ unsigned long mr;
- if (mr)
+ mr = iolog->avg_window[DDIR_READ].mean.u.f + 0.50;
__add_log_sample(iolog, mr, DDIR_READ, 0, elapsed);
- if (mw)
+ }
+ if (iolog->avg_window[DDIR_WRITE].samples) {
+ unsigned long mw;
+
+ mw = iolog->avg_window[DDIR_WRITE].mean.u.f + 0.50;
__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));
+ reset_io_stat(&iolog->avg_window[DDIR_READ]);
+ reset_io_stat(&iolog->avg_window[DDIR_WRITE]);
iolog->avg_last = elapsed;
}
if (spent < td->o.bw_avg_time)
return;
- rate = (td->this_io_bytes[ddir] - td->stat_io_bytes[ddir]) *
- 1000 / spent / 1024;
- add_stat_sample(&ts->bw_stat[ddir], rate);
+ /*
+ * Compute both read and write rates for the interval.
+ */
+ for (ddir = DDIR_READ; ddir <= DDIR_WRITE; ddir++) {
+ uint64_t delta;
+
+ delta = td->this_io_bytes[ddir] - td->stat_io_bytes[ddir];
+ if (!delta)
+ continue; /* No entries for interval */
+
+ rate = delta * 1000 / spent / 1024;
+ add_stat_sample(&ts->bw_stat[ddir], rate);
- if (td->bw_log)
- add_log_sample(td, td->bw_log, rate, ddir, bs);
+ if (td->bw_log)
+ add_log_sample(td, td->bw_log, rate, ddir, bs);
+
+ td->stat_io_bytes[ddir] = td->this_io_bytes[ddir];
+ }
fio_gettime(&td->bw_sample_time, NULL);
- td->stat_io_bytes[ddir] = td->this_io_bytes[ddir];
}
void add_iops_sample(struct thread_data *td, enum fio_ddir ddir,
if (spent < td->o.iops_avg_time)
return;
- iops = ((td->this_io_blocks[ddir] - td->stat_io_blocks[ddir]) * 1000) / spent;
+ /*
+ * Compute both read and write rates for the interval.
+ */
+ for (ddir = DDIR_READ; ddir <= DDIR_WRITE; ddir++) {
+ uint64_t delta;
+
+ delta = td->this_io_blocks[ddir] - td->stat_io_blocks[ddir];
+ if (!delta)
+ continue; /* No entries for interval */
+
+ iops = (delta * 1000) / spent;
+ add_stat_sample(&ts->iops_stat[ddir], iops);
- add_stat_sample(&ts->iops_stat[ddir], iops);
+ if (td->iops_log)
+ add_log_sample(td, td->iops_log, iops, ddir, 0);
- if (td->iops_log) {
- assert(iops);
- add_log_sample(td, td->iops_log, iops, ddir, 0);
+ td->stat_io_blocks[ddir] = td->this_io_blocks[ddir];
}
fio_gettime(&td->iops_sample_time, NULL);
- td->stat_io_blocks[ddir] = td->this_io_blocks[ddir];
}