X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=stat.c;h=abb1b153e69547dae388ca0421be6646684f9d59;hb=bb446c117849b39ece795602774c3716eef6064a;hp=3a785eed9c21568d5cd005675bb4d2ea128e4e8e;hpb=9f8f2064bcb196c10c9d3a2b64b951d796af22b5;p=fio.git diff --git a/stat.c b/stat.c index 3a785eed..abb1b153 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) { @@ -170,12 +195,36 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, free(bw_p); free(iops_p); - if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) - log_info(" slat (msec): min=%5lu, max=%5lu, avg=%5.02f, stdev=%5.02f\n", min, max, mean, dev); + if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) { + const char *base = "(usec)"; + char *minp, *maxp; - if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) - log_info(" clat (msec): min=%5lu, max=%5lu, avg=%5.02f, stdev=%5.02f\n", min, max, mean, dev); + 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->bw_stat[ddir], &min, &max, &mean, &dev)) { double p_of_agg; @@ -184,13 +233,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; @@ -222,12 +321,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%%, 100=%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(" lat (msec): 250=%3.2f%%, 500=%3.2f%%, 750=%3.2f%%, 1000=%3.2f%%, >=2000=%3.2f%%\n", io_u_lat[6], io_u_lat[7], io_u_lat[8], io_u_lat[9], io_u_lat[10]); + show_latencies(io_u_lat_u, io_u_lat_m); } static void show_ddir_status_terse(struct thread_stat *ts, @@ -267,8 +367,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); @@ -288,12 +390,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); @@ -428,11 +534,16 @@ 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++) + + for (k = 0; k <= DDIR_WRITE; k++) { ts->total_io_u[k] += td->ts.total_io_u[k]; + ts->short_io_u[k] += td->ts.short_io_u[k]; + } ts->total_run_time += td->ts.total_run_time; } @@ -548,25 +659,25 @@ void add_agg_sample(unsigned long val, enum fio_ddir ddir) } void add_clat_sample(struct thread_data *td, enum fio_ddir ddir, - unsigned long msec) + unsigned long usec) { struct thread_stat *ts = &td->ts; - add_stat_sample(&ts->clat_stat[ddir], msec); + add_stat_sample(&ts->clat_stat[ddir], usec); if (ts->clat_log) - add_log_sample(td, ts->clat_log, msec, ddir); + add_log_sample(td, ts->clat_log, usec, ddir); } void add_slat_sample(struct thread_data *td, enum fio_ddir ddir, - unsigned long msec) + unsigned long usec) { struct thread_stat *ts = &td->ts; - add_stat_sample(&ts->slat_stat[ddir], msec); + add_stat_sample(&ts->slat_stat[ddir], usec); if (ts->slat_log) - add_log_sample(td, ts->slat_log, msec, ddir); + add_log_sample(td, ts->slat_log, usec, ddir); } void add_bw_sample(struct thread_data *td, enum fio_ddir ddir,