/*
* Discard the error bits and apply the mask to find the
- * index for the buckets in the group
+ * index for the buckets in the group
*/
offset = (FIO_IO_U_PLAT_VAL - 1) & (val >> error_bits);
/* Make sure the index does not exceed (array size - 1) */
- idx = (base + offset) < (FIO_IO_U_PLAT_NR - 1)?
+ idx = (base + offset) < (FIO_IO_U_PLAT_NR - 1) ?
(base + offset) : (FIO_IO_U_PLAT_NR - 1);
return idx;
/* MSB <= (FIO_IO_U_PLAT_BITS-1), cannot be rounded off. Use
* all bits of the sample as index */
- if (idx < (FIO_IO_U_PLAT_VAL << 1) )
+ if (idx < (FIO_IO_U_PLAT_VAL << 1))
return idx;
/* Find the group and compute the minimum value of that group */
- error_bits = (idx >> FIO_IO_U_PLAT_BITS) -1;
+ error_bits = (idx >> FIO_IO_U_PLAT_BITS) - 1;
base = 1 << (error_bits + FIO_IO_U_PLAT_BITS);
/* Find its bucket number of the group */
return cmp;
}
-static unsigned int calc_clat_percentiles(unsigned int *io_u_plat,
- unsigned long nr, fio_fp64_t *plist,
- unsigned int **output,
- unsigned int *maxv,
- unsigned int *minv)
+unsigned int calc_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
+ fio_fp64_t *plist, unsigned int **output,
+ unsigned int *maxv, unsigned int *minv)
{
unsigned long sum = 0;
unsigned int len, i, j = 0;
* isn't a worry. Also note that this does not work for NaN values.
*/
if (len > 1)
- qsort((void*)plist, len, sizeof(plist[0]), double_cmp);
+ qsort((void *)plist, len, sizeof(plist[0]), double_cmp);
/*
* Calculate bucket values, note down max and min values
* Find and display the p-th percentile of clat
*/
static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr,
- fio_fp64_t *plist, uint64_t precision)
+ fio_fp64_t *plist, unsigned int precision)
{
unsigned int len, j = 0, minv, maxv;
unsigned int *ovals;
log_info(" clat percentiles (usec):\n |");
}
- snprintf(fmt, sizeof(fmt), "%%1.%luf", precision);
+ snprintf(fmt, sizeof(fmt), "%%1.%uf", precision);
per_line = (80 - 7) / (precision + 14);
for (j = 0; j < len; j++) {
free(ovals);
}
-static int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max,
- double *mean, double *dev)
+int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max,
+ double *mean, double *dev)
{
double n = is->samples;
if (!rs->max_run[i])
continue;
- p1 = num2str(rs->io_kb[i], 6, rs->kb_base, i2p);
- p2 = num2str(rs->agg[i], 6, rs->kb_base, i2p);
- p3 = num2str(rs->min_bw[i], 6, rs->kb_base, i2p);
- p4 = num2str(rs->max_bw[i], 6, rs->kb_base, i2p);
+ p1 = num2str(rs->io_kb[i], 6, rs->kb_base, i2p, 8);
+ p2 = num2str(rs->agg[i], 6, rs->kb_base, i2p, rs->unit_base);
+ p3 = num2str(rs->min_bw[i], 6, rs->kb_base, i2p, rs->unit_base);
+ p4 = num2str(rs->max_bw[i], 6, rs->kb_base, i2p, rs->unit_base);
- log_info("%s: io=%sB, aggrb=%sB/s, minb=%sB/s, maxb=%sB/s,"
+ log_info("%s: io=%s, aggrb=%s/s, minb=%s/s, maxb=%s/s,"
" mint=%llumsec, maxt=%llumsec\n",
rs->unified_rw_rep ? " MIXED" : ddir_str[i],
- p1, p2, p3, p4, rs->min_run[i], rs->max_run[i]);
+ p1, p2, p3, p4,
+ (unsigned long long) rs->min_run[i],
+ (unsigned long long) rs->max_run[i]);
free(p1);
free(p2);
}
}
-#define ts_total_io_u(ts) \
- ((ts)->total_io_u[DDIR_READ] + (ts)->total_io_u[DDIR_WRITE] +\
- (ts)->total_io_u[DDIR_TRIM])
-
-static void stat_calc_dist(unsigned int *map, unsigned long total,
- double *io_u_dist)
+void stat_calc_dist(unsigned int *map, unsigned long total, double *io_u_dist)
{
int i;
static void stat_calc_lat(struct thread_stat *ts, double *dst,
unsigned int *src, int nr)
{
- unsigned long total = ts_total_io_u(ts);
+ unsigned long total = ddir_rw_sum(ts->total_io_u);
int i;
/*
}
}
-static void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat)
+void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat)
{
stat_calc_lat(ts, io_u_lat, ts->io_u_lat_u, FIO_IO_U_LAT_U_NR);
}
-static void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat)
+void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat)
{
stat_calc_lat(ts, io_u_lat, ts->io_u_lat_m, FIO_IO_U_LAT_M_NR);
}
-static int usec_to_msec(unsigned long *min, unsigned long *max, double *mean,
- double *dev)
+static void display_lat(const char *name, unsigned long min, unsigned long max,
+ double mean, double dev)
{
- if (*min > 1000 && *max > 1000 && *mean > 1000.0 && *dev > 1000.0) {
- *min /= 1000;
- *max /= 1000;
- *mean /= 1000.0;
- *dev /= 1000.0;
- return 0;
- }
+ const char *base = "(usec)";
+ char *minp, *maxp;
- return 1;
+ if (!usec_to_msec(&min, &max, &mean, &dev))
+ base = "(msec)";
+
+ minp = num2str(min, 6, 1, 0, 0);
+ maxp = num2str(max, 6, 1, 0, 0);
+
+ log_info(" %s %s: min=%s, max=%s, avg=%5.02f,"
+ " stdev=%5.02f\n", name, base, minp, maxp, mean, dev);
+
+ free(minp);
+ free(maxp);
}
static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
runt = ts->runtime[ddir];
bw = (1000 * ts->io_bytes[ddir]) / runt;
- io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p);
- bw_p = num2str(bw, 6, 1, i2p);
+ io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p, 8);
+ bw_p = num2str(bw, 6, 1, i2p, ts->unit_base);
iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt;
- iops_p = num2str(iops, 6, 1, 0);
+ iops_p = num2str(iops, 6, 1, 0, 0);
- log_info(" %s: io=%sB, bw=%sB/s, iops=%s, runt=%6llumsec\n",
+ log_info(" %s: io=%s, bw=%s/s, iops=%s, runt=%6llumsec\n",
rs->unified_rw_rep ? "mixed" : ddir_str[ddir],
- io_p, bw_p, iops_p, ts->runtime[ddir]);
+ io_p, bw_p, iops_p,
+ (unsigned long long) ts->runtime[ddir]);
free(io_p);
free(bw_p);
free(iops_p);
- if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) {
- const char *base = "(usec)";
- char *minp, *maxp;
-
- if (!usec_to_msec(&min, &max, &mean, &dev))
- base = "(msec)";
-
- minp = num2str(min, 6, 1, 0);
- maxp = num2str(max, 6, 1, 0);
-
- log_info(" slat %s: min=%s, max=%s, avg=%5.02f,"
- " stdev=%5.02f\n", base, minp, maxp, mean, dev);
-
- free(minp);
- free(maxp);
- }
- if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) {
- const char *base = "(usec)";
- char *minp, *maxp;
-
- if (!usec_to_msec(&min, &max, &mean, &dev))
- base = "(msec)";
-
- minp = num2str(min, 6, 1, 0);
- maxp = num2str(max, 6, 1, 0);
-
- log_info(" clat %s: min=%s, max=%s, avg=%5.02f,"
- " stdev=%5.02f\n", base, minp, maxp, mean, dev);
-
- free(minp);
- free(maxp);
- }
- if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
- const char *base = "(usec)";
- char *minp, *maxp;
-
- if (!usec_to_msec(&min, &max, &mean, &dev))
- base = "(msec)";
-
- minp = num2str(min, 6, 1, 0);
- maxp = num2str(max, 6, 1, 0);
-
- log_info(" lat %s: min=%s, max=%s, avg=%5.02f,"
- " stdev=%5.02f\n", base, minp, maxp, mean, dev);
+ if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
+ display_lat("slat", min, max, mean, dev);
+ if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev))
+ display_lat("clat", min, max, mean, dev);
+ if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev))
+ display_lat(" lat", min, max, mean, dev);
- free(minp);
- free(maxp);
- }
if (ts->clat_percentiles) {
show_clat_percentiles(ts->io_u_plat[ddir],
ts->clat_stat[ddir].samples,
ts->percentile_precision);
}
if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
- double p_of_agg = 100.0;
- const char *bw_str = "KB";
+ double p_of_agg = 100.0, fkb_base = (double)rs->kb_base;
+ const char *bw_str = (rs->unit_base == 1 ? "Kbit" : "KB");
+
+ if (rs->unit_base == 1) {
+ min *= 8.0;
+ max *= 8.0;
+ mean *= 8.0;
+ dev *= 8.0;
+ }
if (rs->agg[ddir]) {
p_of_agg = mean * 100 / (double) rs->agg[ddir];
p_of_agg = 100.0;
}
- if (mean > 999999.9) {
- min /= 1000.0;
- max /= 1000.0;
- mean /= 1000.0;
- dev /= 1000.0;
- bw_str = "MB";
+ if (mean > fkb_base * fkb_base) {
+ min /= fkb_base;
+ max /= fkb_base;
+ mean /= fkb_base;
+ dev /= fkb_base;
+ bw_str = (rs->unit_base == 1 ? "Mbit" : "MB");
}
- log_info(" bw (%s/s) : min=%5lu, max=%5lu, per=%3.2f%%,"
+ log_info(" bw (%-4s/s): min=%5lu, max=%5lu, per=%3.2f%%,"
" avg=%5.02f, stdev=%5.02f\n", bw_str, min, max,
p_of_agg, mean, dev);
}
show_lat(io_u_lat_m, FIO_IO_U_LAT_M_NR, ranges, "msec");
}
-static void show_latencies(double *io_u_lat_u, double *io_u_lat_m)
+static void show_latencies(struct thread_stat *ts)
{
+ double io_u_lat_u[FIO_IO_U_LAT_U_NR];
+ double io_u_lat_m[FIO_IO_U_LAT_M_NR];
+
+ stat_calc_lat_u(ts, io_u_lat_u);
+ stat_calc_lat_m(ts, io_u_lat_m);
+
show_lat_u(io_u_lat_u);
show_lat_m(io_u_lat_m);
}
double usr_cpu, sys_cpu;
unsigned long runtime;
double io_u_dist[FIO_IO_U_MAP_NR];
- double io_u_lat_u[FIO_IO_U_LAT_U_NR];
- double io_u_lat_m[FIO_IO_U_LAT_M_NR];
time_t time_p;
char time_buf[64];
if (ts->io_bytes[DDIR_TRIM])
show_ddir_status(rs, ts, DDIR_TRIM);
- stat_calc_lat_u(ts, io_u_lat_u);
- stat_calc_lat_m(ts, io_u_lat_m);
- show_latencies(io_u_lat_u, io_u_lat_m);
+ show_latencies(ts);
runtime = ts->total_run_time;
if (runtime) {
sys_cpu = 0;
}
- log_info(" cpu : usr=%3.2f%%, sys=%3.2f%%, ctx=%lu, majf=%lu,"
- " minf=%lu\n", usr_cpu, sys_cpu, ts->ctx, ts->majf, ts->minf);
+ log_info(" cpu : usr=%3.2f%%, sys=%3.2f%%, ctx=%llu,"
+ " majf=%llu, minf=%llu\n", usr_cpu, sys_cpu,
+ (unsigned long long) ts->ctx,
+ (unsigned long long) ts->majf,
+ (unsigned long long) ts->minf);
- stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist);
+ stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
log_info(" IO depths : 1=%3.1f%%, 2=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%,"
" 16=%3.1f%%, 32=%3.1f%%, >=64=%3.1f%%\n", io_u_dist[0],
io_u_dist[1], io_u_dist[2],
io_u_dist[1], io_u_dist[2],
io_u_dist[3], io_u_dist[4],
io_u_dist[5], io_u_dist[6]);
- log_info(" issued : total=r=%lu/w=%lu/d=%lu,"
- " short=r=%lu/w=%lu/d=%lu\n",
- ts->total_io_u[0], ts->total_io_u[1],
- ts->total_io_u[2],
- ts->short_io_u[0], ts->short_io_u[1],
- ts->short_io_u[2]);
+ log_info(" issued : total=r=%llu/w=%llu/d=%llu,"
+ " short=r=%llu/w=%llu/d=%llu\n",
+ (unsigned long long) ts->total_io_u[0],
+ (unsigned long long) ts->total_io_u[1],
+ (unsigned long long) ts->total_io_u[2],
+ (unsigned long long) ts->short_io_u[0],
+ (unsigned long long) ts->short_io_u[1],
+ (unsigned long long) ts->short_io_u[2]);
if (ts->continue_on_error) {
- log_info(" errors : total=%lu, first_error=%d/<%s>\n",
- ts->total_err_count,
+ log_info(" errors : total=%llu, first_error=%d/<%s>\n",
+ (unsigned long long)ts->total_err_count,
ts->first_error,
strerror(ts->first_error));
}
iops = (1000 * (uint64_t) ts->total_io_u[ddir]) / runt;
}
- log_info(";%llu;%llu;%llu;%llu", ts->io_bytes[ddir] >> 10, bw, iops,
- ts->runtime[ddir]);
+ log_info(";%llu;%llu;%llu;%llu",
+ (unsigned long long) ts->io_bytes[ddir] >> 10, bw, iops,
+ (unsigned long long) ts->runtime[ddir]);
if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
log_info(";%lu;%lu;%f;%f", min, max, mean, dev);
if (ovals)
free(ovals);
- if (!calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
+ if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
if (rs->agg[ddir]) {
p_of_agg = mean * 100 / (double) rs->agg[ddir];
if (p_of_agg > 100.0)
}
static void show_thread_status_terse_v2(struct thread_stat *ts,
- struct group_run_stats *rs)
+ struct group_run_stats *rs)
{
double io_u_dist[FIO_IO_U_MAP_NR];
double io_u_lat_u[FIO_IO_U_LAT_U_NR];
sys_cpu = 0;
}
- log_info(";%f%%;%f%%;%lu;%lu;%lu", usr_cpu, sys_cpu, ts->ctx, ts->majf,
- ts->minf);
+ log_info(";%f%%;%f%%;%llu;%llu;%llu", usr_cpu, sys_cpu,
+ (unsigned long long) ts->ctx,
+ (unsigned long long) ts->majf,
+ (unsigned long long) ts->minf);
/* Calc % distribution of IO depths, usecond, msecond latency */
- stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist);
+ stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
stat_calc_lat_u(ts, io_u_lat_u);
stat_calc_lat_m(ts, io_u_lat_m);
log_info(";%3.2f%%", io_u_lat_m[i]);
/* 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(";%llu;%d", (unsigned long long) ts->total_err_count, ts->first_error);
log_info("\n");
/* Additional output if description is set */
sys_cpu = 0;
}
- log_info(";%f%%;%f%%;%lu;%lu;%lu", usr_cpu, sys_cpu, ts->ctx, ts->majf,
- ts->minf);
+ log_info(";%f%%;%f%%;%llu;%llu;%llu", usr_cpu, sys_cpu,
+ (unsigned long long) ts->ctx,
+ (unsigned long long) ts->majf,
+ (unsigned long long) ts->minf);
/* Calc % distribution of IO depths, usecond, msecond latency */
- stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist);
+ stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
stat_calc_lat_u(ts, io_u_lat_u);
stat_calc_lat_m(ts, io_u_lat_m);
/* 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(";%llu;%d", (unsigned long long) ts->total_err_count, ts->first_error);
/* Additional output if description is set */
if (strlen(ts->description))
/* Calc % distribution of IO depths, usecond, msecond latency */
- stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist);
+ stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
stat_calc_lat_u(ts, io_u_lat_u);
stat_calc_lat_m(ts, io_u_lat_m);
struct thread_stat *threadstats, *ts;
int i, j, nr_ts, last_ts, idx;
int kb_base_warned = 0;
+ int unit_base_warned = 0;
struct json_object *root = NULL;
struct json_array *array = NULL;
else
memset(ts->description, 0, FIO_JOBNAME_SIZE);
+ /*
+ * If multiple entries in this group, this is
+ * the first member.
+ */
+ ts->thread_number = td->thread_number;
ts->groupid = td->groupid;
/*
ts->pid = td->pid;
ts->kb_base = td->o.kb_base;
+ ts->unit_base = td->o.unit_base;
ts->unified_rw_rep = td->o.unified_rw_rep;
} else if (ts->kb_base != td->o.kb_base && !kb_base_warned) {
log_info("fio: kb_base differs for jobs in group, using"
" %u as the base\n", ts->kb_base);
kb_base_warned = 1;
+ } else if (ts->unit_base != td->o.unit_base && !unit_base_warned) {
+ log_info("fio: unit_base differs for jobs in group, using"
+ " %u as the base\n", ts->unit_base);
+ unit_base_warned = 1;
}
ts->continue_on_error = td->o.continue_on_error;
ts = &threadstats[i];
rs = &runstats[ts->groupid];
rs->kb_base = ts->kb_base;
+ rs->unit_base = ts->unit_base;
rs->unified_rw_rep += ts->unified_rw_rep;
for (j = 0; j < DDIR_RWDIR_CNT; j++) {
if (is_backend)
fio_server_send_du();
- else if (output_format == FIO_OUTPUT_NORMAL)
+ else if (output_format == FIO_OUTPUT_NORMAL) {
show_disk_util(0, NULL);
-
- show_idle_prof_stats(FIO_OUTPUT_NORMAL, NULL);
+ show_idle_prof_stats(FIO_OUTPUT_NORMAL, NULL);
+ }
free(runstats);
free(threadstats);
}
-static void *__show_running_run_stats(void *arg)
+static void *__show_running_run_stats(void fio_unused *arg)
{
struct thread_data *td;
unsigned long long *rt;
if (td_trim(td) && td->io_bytes[DDIR_TRIM])
td->ts.runtime[DDIR_TRIM] += rt[i];
- update_rusage_stat(td);
+ td->update_rusage = 1;
td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ];
td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE];
td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM];
td->ts.total_run_time = mtime_since(&td->epoch, &tv);
}
+ for_each_td(td, i) {
+ if (td->rusage_sem) {
+ td->update_rusage = 1;
+ fio_mutex_down(td->rusage_sem);
+ }
+ td->update_rusage = 0;
+ }
+
show_run_stats();
for_each_td(td, i) {