X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=stat.c;h=401e1f2a6084575c11f536d17c41764e44e79082;hp=1205bdd26ec8ff8943b44a27fdc6f64eedc8aba4;hb=dc372f07b450e3b4c758d7a7fdaaca6c21843398;hpb=d85f5118c41a112c3b8a58cc6908d00294bfb78d diff --git a/stat.c b/stat.c index 1205bdd2..401e1f2a 100644 --- a/stat.c +++ b/stat.c @@ -82,7 +82,7 @@ static int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, if (n > 1.0) *dev = sqrt(is->S / (n - 1.0)); else - *dev = -1.0; + *dev = 0; return 1; } @@ -131,21 +131,46 @@ static void stat_calc_dist(struct thread_stat *ts, double *io_u_dist) } } -static void stat_calc_lat(struct thread_stat *ts, double *io_u_lat) +static void stat_calc_lat(struct thread_stat *ts, double *dst, + unsigned int *src, int nr) { int i; /* * Do latency distribution calculations */ - for (i = 0; i < FIO_IO_U_LAT_NR; i++) { - io_u_lat[i] = (double) ts->io_u_lat[i] / (double) ts_total_io_u(ts); - io_u_lat[i] *= 100.0; - if (io_u_lat[i] < 0.01 && ts->io_u_lat[i]) - io_u_lat[i] = 0.01; + for (i = 0; i < nr; i++) { + dst[i] = (double) src[i] / (double) ts_total_io_u(ts); + dst[i] *= 100.0; + if (dst[i] < 0.01 && src[i]) + dst[i] = 0.01; } } +static 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) +{ + 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) +{ + if (*min > 1000 && *max > 1000 && *mean > 1000.0 && *dev > 1000.0) { + *min /= 1000; + *max /= 1000; + *mean /= 1000.0; + *dev /= 1000.0; + return 0; + } + + return 1; +} + static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, int ddir) { @@ -173,25 +198,17 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) { const char *base = "(usec)"; - if (min > 1000 && max > 1000 && mean > 1000.0 && dev > 1000.0) { - min /= 1000; - max /= 1000; - mean /= 1000.0; - dev /= 1000.0; + if (!usec_to_msec(&min, &max, &mean, &dev)) base = "(msec)"; - } + log_info(" slat %s: min=%5lu, max=%5lu, avg=%5.02f, stdev=%5.02f\n", base, min, max, mean, dev); } if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) { const char *base = "(usec)"; - if (min > 1000 && max > 1000 && mean > 1000.0 && dev > 1000.0) { - min /= 1000; - max /= 1000; - mean /= 1000.0; - dev /= 1000.0; - base = "(msec)"; - } + if (!usec_to_msec(&min, &max, &mean, &dev)) + base = "(msec)"; + log_info(" clat %s: min=%5lu, max=%5lu, avg=%5.02f, stdev=%5.02f\n", base, min, max, mean, dev); } if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { @@ -202,13 +219,63 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, } } +static void show_lat(double *io_u_lat, int nr, const char **ranges, + const char *msg) +{ + int new_line = 1, i, line = 0; + + for (i = 0; i < nr; i++) { + if (io_u_lat[i] <= 0.0) + continue; + if (new_line) { + if (line) + log_info("\n"); + log_info(" lat (%s): ", msg); + new_line = 0; + line = 0; + } + if (line) + log_info(", "); + log_info("%s%3.2f%%", ranges[i], io_u_lat[i]); + line++; + if (line == 5) + new_line = 1; + } +} + +static void show_lat_u(double *io_u_lat_u) +{ + const char *ranges[] = { "2=", "4=", "10=", "20=", "50=", "100=", + "250=", "500=", "750=", "1000=", }; + + show_lat(io_u_lat_u, FIO_IO_U_LAT_U_NR, ranges, "usec"); +} + +static void show_lat_m(double *io_u_lat_m) +{ + const char *ranges[] = { "2=", "4=", "10=", "20=", "50=", "100=", + "250=", "500=", "750=", "1000=", "2000=", + ">=2000=", }; + + 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) +{ + show_lat_u(io_u_lat_u); + log_info("\n"); + show_lat_m(io_u_lat_m); + log_info("\n"); +} + static void show_thread_status(struct thread_stat *ts, struct group_run_stats *rs) { double usr_cpu, sys_cpu; unsigned long runtime; double io_u_dist[FIO_IO_U_MAP_NR]; - double io_u_lat[FIO_IO_U_LAT_NR]; + double io_u_lat_u[FIO_IO_U_LAT_U_NR]; + double io_u_lat_m[FIO_IO_U_LAT_M_NR]; if (!(ts->io_bytes[0] + ts->io_bytes[1])) return; @@ -240,14 +307,13 @@ static void show_thread_status(struct thread_stat *ts, log_info(" cpu : usr=%3.2f%%, sys=%3.2f%%, ctx=%lu\n", usr_cpu, sys_cpu, ts->ctx); stat_calc_dist(ts, io_u_dist); - stat_calc_lat(ts, io_u_lat); + stat_calc_lat_u(ts, io_u_lat_u); + stat_calc_lat_m(ts, io_u_lat_m); 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[3], io_u_dist[4], io_u_dist[5], io_u_dist[6]); log_info(" issued r/w: total=%lu/%lu, short=%lu/%lu\n", ts->total_io_u[0], ts->total_io_u[1], ts->short_io_u[0], ts->short_io_u[1]); - log_info(" lat (msec): 2=%3.2f%%, 4=%3.2f%%, 10=%3.2f%%, 20=%3.2f%%, 50=%3.2f%%\n", io_u_lat[0], io_u_lat[1], io_u_lat[2], io_u_lat[3], io_u_lat[4]); - log_info(" lat (msec): 100=%3.2f%%, 250=%3.2f%%, 500=%3.2f%%, 750=%3.2f%%\n", io_u_lat[5], io_u_lat[6], io_u_lat[7], io_u_lat[8]); - log_info(" lat (msec): 1000=%3.2f%%, 2000=%3.2f%%, >=2000=%3.2f%%\n", io_u_lat[9], io_u_lat[10], io_u_lat[11]); + show_latencies(io_u_lat_u, io_u_lat_m); } static void show_ddir_status_terse(struct thread_stat *ts, @@ -287,8 +353,10 @@ static void show_thread_status_terse(struct thread_stat *ts, struct group_run_stats *rs) { double io_u_dist[FIO_IO_U_MAP_NR]; - double io_u_lat[FIO_IO_U_LAT_NR]; + double io_u_lat_u[FIO_IO_U_LAT_U_NR]; + double io_u_lat_m[FIO_IO_U_LAT_M_NR]; double usr_cpu, sys_cpu; + int i; log_info("%s;%d;%d", ts->name, ts->groupid, ts->error); @@ -308,12 +376,16 @@ static void show_thread_status_terse(struct thread_stat *ts, log_info(";%f%%;%f%%;%lu", usr_cpu, sys_cpu, ts->ctx); stat_calc_dist(ts, io_u_dist); - stat_calc_lat(ts, io_u_lat); + stat_calc_lat_u(ts, io_u_lat_u); + stat_calc_lat_m(ts, io_u_lat_m); log_info(";%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%", io_u_dist[0], 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(";%3.2f%%;%3.2f%%;%3.2f%%;%3.2f%%;%3.2f%%;%3.2f%%\n", io_u_lat[0], io_u_lat[1], io_u_lat[2], io_u_lat[3], io_u_lat[4], io_u_lat[5]); - log_info(";%3.2f%%;%3.2f%%;%3.2f%%;%3.2f%%;%3.2f%%", io_u_lat[6], io_u_lat[7], io_u_lat[8], io_u_lat[9], io_u_lat[10]); + for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) + log_info(";%3.2f%%", io_u_lat_u[i]); + for (i = 0; i < FIO_IO_U_LAT_M_NR; i++) + log_info(";%3.2f%%", io_u_lat_m[i]); + log_info("\n"); if (ts->description) log_info(";%s", ts->description); @@ -448,8 +520,11 @@ void show_run_stats(void) for (k = 0; k < FIO_IO_U_MAP_NR; k++) ts->io_u_map[k] += td->ts.io_u_map[k]; - for (k = 0; k < FIO_IO_U_LAT_NR; k++) - ts->io_u_lat[k] += td->ts.io_u_lat[k]; + for (k = 0; k < FIO_IO_U_LAT_U_NR; k++) + ts->io_u_lat_u[k] += td->ts.io_u_lat_u[k]; + for (k = 0; k < FIO_IO_U_LAT_M_NR; k++) + ts->io_u_lat_m[k] += td->ts.io_u_lat_m[k]; + for (k = 0; k <= DDIR_WRITE; k++) { ts->total_io_u[k] += td->ts.total_io_u[k];