The following changes since commit 2316296a514711bb388d87b34742c04bb561d986: zipf: seed zipf/pareto rand with filename hash and job id (2012-11-07 19:47:47 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Jens Axboe (6): Zipf theta must be different than 1.0 zipf: cap range calculation at 10M zipf: kill debug "generating series" messages Use ETIMEDOUT instead of ETIME for exceeding max latency Use more portable construct for setting/checking CC Makefile: 2nd go at making CC assignment/check actually work Makefile | 4 ++- io_u.c | 4 +- lib/zipf.c | 79 +++++++--------------------------------------------------- options.c | 8 ++++- t/genzipf.c | 4 +++ 5 files changed, 25 insertions(+), 74 deletions(-) --- Diff of recent changes: diff --git a/Makefile b/Makefile index 7e877fe..0db757b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -CC ?= gcc +ifneq ($(origin CC), environment) +CC = gcc +endif DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG CPPFLAGS= -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \ $(DEBUGFLAGS) diff --git a/io_u.c b/io_u.c index 551c5ff..119dd65 100644 --- a/io_u.c +++ b/io_u.c @@ -1359,8 +1359,8 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u, if (td->o.max_latency && tusec > td->o.max_latency) { if (!td->error) log_err("fio: latency of %lu usec exceeds specified max (%u usec)\n", tusec, td->o.max_latency); - td_verror(td, ETIME, "max latency exceeded"); - icd->error = ETIME; + td_verror(td, ETIMEDOUT, "max latency exceeded"); + icd->error = ETIMEDOUT; } } diff --git a/lib/zipf.c b/lib/zipf.c index c7bb8a8..41e2055 100644 --- a/lib/zipf.c +++ b/lib/zipf.c @@ -10,82 +10,23 @@ #include "zipf.h" #include "../minmax.h" #include "../hash.h" -#include "../os/os.h" -struct fio_zipf_disk { - uint64_t ver_magic; - uint64_t nranges; - uint64_t zetan; -}; - -#define FIO_ZIPF_DISK_MAGIC 0x7a697066 -#define FIO_ZIPF_DISK_VER 1 -#define FIO_ZIPF_MAGIC ((FIO_ZIPF_DISK_MAGIC << 16) | FIO_ZIPF_DISK_VER) - -static void write_zipf(struct zipf_state *zs) -{ - struct fio_zipf_disk f; - char tmp[80]; - int fd; - - sprintf(tmp, "fio.zipf.%f.%llu", zs->theta, (unsigned long long) zs->nranges); - fd = open(tmp, O_CREAT | O_WRONLY, 0644); - if (fd == -1) - return; - - f.ver_magic = __cpu_to_le64(FIO_ZIPF_MAGIC); - f.nranges = __cpu_to_le64(zs->nranges); - f.zetan = __cpu_to_le64(fio_double_to_uint64(zs->zetan)); - if (write(fd, &f, sizeof(f)) != sizeof(f)) - unlink(tmp); - - close(fd); -} +#define ZIPF_MAX_GEN 10000000 static void zipf_update(struct zipf_state *zs) { + unsigned long to_gen; unsigned int i; - log_info("fio: generating zetan for theta=%f, ranges=%lu\n", zs->theta, zs->nranges); + /* + * It can become very costly to generate long sequences. Just cap it at + * 10M max, that should be doable in 1-2s on even slow machines. + * Precision will take a slight hit, but nothing major. + */ + to_gen = min(zs->nranges, ZIPF_MAX_GEN); - for (i = 0; i < zs->nranges; i++) + for (i = 0; i < to_gen; i++) zs->zetan += pow(1.0 / (double) (i + 1), zs->theta); - - write_zipf(zs); -} - -static void zipf_load_gen_zeta(struct zipf_state *zs) -{ - struct fio_zipf_disk f; - char tmp[80]; - int fd; - - sprintf(tmp, "fio.zipf.%f.%llu", zs->theta, (unsigned long long) zs->nranges); - fd = open(tmp, O_RDONLY); - if (fd == -1) { -punt: - zipf_update(zs); - return; - } - - if (read(fd, &f, sizeof(f)) != sizeof(f)) { - close(fd); - goto punt; - } - - close(fd); - - f.ver_magic = le64_to_cpu(f.ver_magic); - f.nranges = le64_to_cpu(f.nranges); - f.zetan = le64_to_cpu(f.zetan); - - if (f.ver_magic != FIO_ZIPF_MAGIC) { - unlink(tmp); - goto punt; - } - - zs->zetan = fio_uint64_to_double(f.zetan); - zs->nranges = f.nranges; } static void shared_rand_init(struct zipf_state *zs, unsigned long nranges, @@ -106,7 +47,7 @@ void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, zs->theta = theta; zs->zeta2 = pow(1.0, zs->theta) + pow(0.5, zs->theta); - zipf_load_gen_zeta(zs); + zipf_update(zs); } unsigned long long zipf_next(struct zipf_state *zs) diff --git a/options.c b/options.c index c240692..ae85988 100644 --- a/options.c +++ b/options.c @@ -750,9 +750,13 @@ static int str_random_distribution_cb(void *data, const char *str) free(nr); - if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) + if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) { + if (val == 1.00) { + log_err("fio: zipf theta must different than 1.0\n"); + return 1; + } td->o.zipf_theta = val; - else { + } else { if (val <= 0.00 || val >= 1.00) { log_err("fio: pareto input out of range (0 < input < 1.0)\n"); return 1; diff --git a/t/genzipf.c b/t/genzipf.c index dfb8992..e625def 100644 --- a/t/genzipf.c +++ b/t/genzipf.c @@ -141,6 +141,10 @@ int main(int argc, char *argv[]) printf("pareto input must be > 0.00 and < 1.00\n"); return 1; } + if (val == 1.0 && use_zipf) { + printf("zipf input must be different than 1.0\n"); + return 1; + } nranges = DEF_NR; output_nranges = DEF_NR_OUTPUT; -- 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