X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=stat.c;h=8b032b881d93d8fe1dc692a1c38898be42848bcd;hp=68744281a92de519cbb1f350fb459dfcca517cfd;hb=2f99deb0895b2d0b618e6e72c74add7192b4d73f;hpb=5daa4ebed724cb0223dac4a1386e068f59722dab diff --git a/stat.c b/stat.c index 68744281..8b032b88 100644 --- a/stat.c +++ b/stat.c @@ -114,11 +114,9 @@ static int double_cmp(const void *a, const void *b) 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; @@ -234,8 +232,8 @@ out: 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; @@ -287,11 +285,7 @@ void show_group_stats(struct group_run_stats *rs) } } -#define ts_total_io_u(ts) \ - ((ts)->total_io_u[0] + (ts)->total_io_u[1]) - -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; @@ -329,28 +323,33 @@ static void stat_calc_lat(struct thread_stat *ts, double *dst, } } -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); + maxp = num2str(max, 6, 1, 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, @@ -386,54 +385,13 @@ 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)) { - 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, @@ -510,8 +468,14 @@ static void show_lat_m(double *io_u_lat_m) 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); } @@ -521,8 +485,6 @@ 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_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]) && !(ts->total_io_u[0] + ts->total_io_u[1])) @@ -546,9 +508,7 @@ void show_thread_status(struct thread_stat *ts, struct group_run_stats *rs) if (ts->io_bytes[DDIR_WRITE]) show_ddir_status(rs, ts, DDIR_WRITE); - 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) { @@ -1291,8 +1251,8 @@ void add_bw_sample(struct thread_data *td, enum fio_ddir ddir, unsigned int bs, spent = mtime_since(&td->bw_sample_time, t); if (spent < td->o.bw_avg_time) return; - - /* + + /* * Compute both read and write rates for the interval. */ for (ddir = DDIR_READ; ddir <= DDIR_WRITE; ddir++) { @@ -1327,13 +1287,24 @@ 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; - add_stat_sample(&ts->iops_stat[ddir], iops); + 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); - if (td->iops_log) - add_log_sample(td, td->iops_log, iops, ddir, 0); + if (td->iops_log) + 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]; }