unsigned int random_distribution;
double zipf_theta;
+ double pareto_h;
unsigned int hugepage_size;
unsigned int rw_min_bs;
enum {
FIO_RAND_DIST_RANDOM = 0,
FIO_RAND_DIST_ZIPF,
+ FIO_RAND_DIST_PARETO,
};
#endif
range_size = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
nranges = (td->o.size + range_size - 1) / range_size;
- zipf_init(&td->zipf, nranges, td->o.zipf_theta);
+
+ if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
+ zipf_init(&td->zipf, nranges, td->o.zipf_theta);
+ else
+ pareto_init(&td->zipf, nranges, td->o.pareto_h);
}
/*
return 0;
}
-static int __get_next_rand_offset_zipf(struct thread_data *td, struct fio_file *f,
- enum fio_ddir ddir, unsigned long long *b)
+static int __get_next_rand_offset_zipf(struct thread_data *td,
+ struct fio_file *f, enum fio_ddir ddir,
+ unsigned long long *b)
{
*b = zipf_next(&td->zipf);
return 0;
}
+static int __get_next_rand_offset_pareto(struct thread_data *td,
+ struct fio_file *f, enum fio_ddir ddir,
+ unsigned long long *b)
+{
+ *b = pareto_next(&td->zipf);
+ return 0;
+}
+
static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
enum fio_ddir ddir, unsigned long long *b)
{
return __get_next_rand_offset(td, f, ddir, b);
else if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
return __get_next_rand_offset_zipf(td, f, ddir, b);
+ else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
+ return __get_next_rand_offset_pareto(td, f, ddir, b);
log_err("fio: unknown random distribution: %d\n", td->o.random_distribution);
return 1;
return val - 1;
}
+
+void pareto_init(struct zipf_state *zs, unsigned long nranges, double h)
+{
+ memset(zs, 0, sizeof(*zs));
+
+ zs->nranges = nranges;
+ zs->pareto_pow = log(h) / log(1.0 - h);
+
+ init_rand(&zs->rand);
+}
+
+unsigned long long pareto_next(struct zipf_state *zs)
+{
+ double rand = (double) __rand(&zs->rand) / (double) FRAND_MAX;
+ unsigned long long n = zs->nranges - 1;
+
+ return n * pow(rand, zs->pareto_pow);
+}
double theta;
double zeta2;
double zetan;
+ double pareto_pow;
struct frand_state rand;
};
void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta);
unsigned long long zipf_next(struct zipf_state *zs);
+void pareto_init(struct zipf_state *zs, unsigned long nranges, double h);
+unsigned long long pareto_next(struct zipf_state *zs);
+
#endif
double val;
char *nr;
- if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
+ if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
+ val = 1.1;
+ else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
+ val = 0.2;
+ else
return 0;
nr = get_opt_postfix(str);
- if (!nr)
- val = 0.6;
- else if (!str_to_float(nr, &val)) {
+ if (nr && !str_to_float(nr, &val)) {
log_err("fio: random postfix parsing failed\n");
free(nr);
return 1;
}
- td->o.zipf_theta = val;
+ if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
+ td->o.zipf_theta = val;
+ else
+ td->o.pareto_h = val;
+
free(nr);
return 0;
}
.oval = FIO_RAND_DIST_ZIPF,
.help = "Zipf distribution",
},
+ { .ival = "pareto",
+ .oval = FIO_RAND_DIST_PARETO,
+ .help = "Pareto distribution",
+ },
},
},
{