The following changes since commit 723d7b34839f460839158b207ce2d3b28e17f31c: Add --build-32bit-win switch to configure --help output. (2013-02-05 21:17:35 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (3): Cleanup the percentile output formatting Handle normal output wrapping of the percentile list Get rid of fallocate on Windows Vincent Kang Fu (1): Handle percentile lists with higher precision that 2 digits configure | 1 - fio.h | 1 + init.c | 1 + options.c | 1 + os/windows/posix.c | 47 ----------------------------------------------- parse.c | 34 +++++++++++++++++++++++++++++++++- stat.c | 28 +++++++++++++++++----------- stat.h | 1 + 8 files changed, 54 insertions(+), 60 deletions(-) --- Diff of recent changes: diff --git a/configure b/configure index 258c805..d7ca77c 100755 --- a/configure +++ b/configure @@ -200,7 +200,6 @@ CYGWIN*) fi output_sym "CONFIG_FADVISE" output_sym "CONFIG_SOCKLEN_T" - output_sym "CONFIG_POSIX_FALLOCATE" output_sym "CONFIG_FADVISE" output_sym "CONFIG_SFAA" output_sym "CONFIG_RUSAGE_THREAD" diff --git a/fio.h b/fio.h index 370ddaa..43f4854 100644 --- a/fio.h +++ b/fio.h @@ -248,6 +248,7 @@ struct thread_options { unsigned int trim_zero; unsigned long long trim_backlog; unsigned int clat_percentiles; + unsigned int percentile_precision; /* digits after decimal for percentiles */ fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN]; char *read_iolog_file; diff --git a/init.c b/init.c index 52665f0..60ba299 100644 --- a/init.c +++ b/init.c @@ -867,6 +867,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->mutex = fio_mutex_init(FIO_MUTEX_LOCKED); td->ts.clat_percentiles = td->o.clat_percentiles; + td->ts.percentile_precision = td->o.percentile_precision; memcpy(td->ts.percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list)); for (i = 0; i < DDIR_RWDIR_CNT; i++) { diff --git a/options.c b/options.c index 4522fe4..42a2ea0 100644 --- a/options.c +++ b/options.c @@ -2434,6 +2434,7 @@ static struct fio_option options[FIO_MAX_OPTS] = { .name = "percentile_list", .type = FIO_OPT_FLOAT_LIST, .off1 = td_var_offset(percentile_list), + .off2 = td_var_offset(percentile_precision), .help = "Specify a custom list of percentiles to report", .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99", .maxlen = FIO_IO_U_LIST_MAX_LEN, diff --git a/os/windows/posix.c b/os/windows/posix.c index 05fa5a9..de67911 100755 --- a/os/windows/posix.c +++ b/os/windows/posix.c @@ -408,53 +408,6 @@ char *basename(char *path) return name; } -int posix_fallocate(int fd, off_t offset, off_t len) -{ - const int BUFFER_SIZE = 256 * 1024; - int rc = 0; - char *buf; - unsigned int write_len; - unsigned int bytes_written; - off_t bytes_remaining = len; - - if (len == 0 || offset < 0) - return EINVAL; - - buf = malloc(BUFFER_SIZE); - - if (buf == NULL) - return ENOMEM; - - memset(buf, 0, BUFFER_SIZE); - - int64_t prev_pos = _telli64(fd); - - if (_lseeki64(fd, offset, SEEK_SET) == -1) - return errno; - - while (bytes_remaining > 0) { - if (bytes_remaining < BUFFER_SIZE) - write_len = (unsigned int)bytes_remaining; - else - write_len = BUFFER_SIZE; - - bytes_written = _write(fd, buf, write_len); - if (bytes_written == -1) { - rc = errno; - break; - } - - /* Don't allow Windows to cache the write: flush it to disk */ - _commit(fd); - - bytes_remaining -= bytes_written; - } - - free(buf); - _lseeki64(fd, prev_pos, SEEK_SET); - return rc; -} - int ftruncate(int fildes, off_t length) { BOOL bSuccess; diff --git a/parse.c b/parse.c index 4ce29c1..51cefca 100644 --- a/parse.c +++ b/parse.c @@ -502,12 +502,27 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, break; } case FIO_OPT_FLOAT_LIST: { + char *cp2; + + if (first) { + /* + ** Initialize precision to 0 and zero out list + ** in case specified list is shorter than default + */ + ul2 = 0; + ilp = td_var(data, o->off2); + *ilp = ul2; + + flp = td_var(data, o->off1); + for(i = 0; i < o->maxlen; i++) + flp[i].u.f = 0.0; + } if (curr >= o->maxlen) { log_err("the list exceeding max length %d\n", o->maxlen); return 1; } - if (!str_to_float(ptr, &uf)){ + if (!str_to_float(ptr, &uf)) { log_err("not a floating point value: %s\n", ptr); return 1; } @@ -525,6 +540,23 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, flp = td_var(data, o->off1); flp[curr].u.f = uf; + /* + ** Calculate precision for output by counting + ** number of digits after period. Find first + ** period in entire remaining list each time + */ + cp2 = strchr(ptr, '.'); + if (cp2 != NULL) { + int len = 0; + + while (*++cp2 != '\0' && *cp2 >= '0' && *cp2 <= '9') + len++; + + ilp = td_var(data, o->off2); + if (len > *ilp) + *ilp = len; + } + break; } case FIO_OPT_STR_STORE: { diff --git a/stat.c b/stat.c index fb5ff64..28acc23 100644 --- a/stat.c +++ b/stat.c @@ -182,11 +182,12 @@ static unsigned int calc_clat_percentiles(unsigned int *io_u_plat, * 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) + fio_fp64_t *plist, uint64_t precision) { unsigned int len, j = 0, minv, maxv; unsigned int *ovals; - int is_last, scale_down; + int is_last, per_line, scale_down; + char fmt[32]; len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv); if (!len) @@ -204,20 +205,23 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, log_info(" clat percentiles (usec):\n |"); } + snprintf(fmt, sizeof(fmt), "%%1.%luf", precision); + per_line = (80 - 7) / (precision + 14); + for (j = 0; j < len; j++) { - char fbuf[8]; + char fbuf[16], *ptr = fbuf; /* for formatting */ - if (j != 0 && (j % 4) == 0) + if (j != 0 && (j % per_line) == 0) log_info(" |"); /* end of the list */ is_last = (j == len - 1); if (plist[j].u.f < 10.0) - sprintf(fbuf, " %2.2f", plist[j].u.f); - else - sprintf(fbuf, "%2.2f", plist[j].u.f); + ptr += sprintf(fbuf, " "); + + snprintf(ptr, sizeof(fbuf), fmt, plist[j].u.f); if (scale_down) ovals[j] = (ovals[j] + 999) / 1000; @@ -227,7 +231,7 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, if (is_last) break; - if (j % 4 == 3) /* for formatting */ + if ((j % per_line) == per_line - 1) /* for formatting */ log_info("\n"); } @@ -440,7 +444,8 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, if (ts->clat_percentiles) { show_clat_percentiles(ts->io_u_plat[ddir], ts->clat_stat[ddir].samples, - ts->percentile_list); + ts->percentile_list, + ts->percentile_precision); } if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { double p_of_agg = 100.0; @@ -655,7 +660,7 @@ static void show_ddir_status_terse(struct thread_stat *ts, log_info(";0%%=0"); continue; } - log_info(";%2.2f%%=%u", ts->percentile_list[i].u.f, ovals[i]); + log_info(";%f%%=%u", ts->percentile_list[i].u.f, ovals[i]); } if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) @@ -753,7 +758,7 @@ static void add_ddir_status_json(struct thread_stat *ts, json_object_add_value_int(percentile_object, "0.00", 0); continue; } - snprintf(buf, sizeof(buf), "%2.2f", ts->percentile_list[i].u.f); + snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f); json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]); } @@ -1210,6 +1215,7 @@ void show_run_stats(void) ts = &threadstats[j]; ts->clat_percentiles = td->o.clat_percentiles; + ts->percentile_precision = td->o.percentile_precision; memcpy(ts->percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list)); idx++; diff --git a/stat.h b/stat.h index 97186c1..98ae4c8 100644 --- a/stat.h +++ b/stat.h @@ -144,6 +144,7 @@ struct thread_stat { * IO depth and latency stats */ uint64_t clat_percentiles; + uint64_t percentile_precision; fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN]; uint32_t io_u_map[FIO_IO_U_MAP_NR]; -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html