projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
zipf/pareto: mix blocks with hashing
[fio.git]
/
lib
/
zipf.c
diff --git
a/lib/zipf.c
b/lib/zipf.c
index 28e8d77e5602d13b95e73e561ce4df418750d441..527ae294cf9afd6212151e004e2220163e25f888 100644
(file)
--- a/
lib/zipf.c
+++ b/
lib/zipf.c
@@
-9,6
+9,7
@@
#include "../log.h"
#include "zipf.h"
#include "../minmax.h"
#include "../log.h"
#include "zipf.h"
#include "../minmax.h"
+#include "../hash.h"
#include "../os/os.h"
struct fio_zipf_disk {
#include "../os/os.h"
struct fio_zipf_disk {
@@
-124,7
+125,7
@@
unsigned long long zipf_next(struct zipf_state *zs)
else
val = 1 + (unsigned long long)(n * pow(eta*rand_uni - eta + 1.0, alpha));
else
val = 1 + (unsigned long long)(n * pow(eta*rand_uni - eta + 1.0, alpha));
- return
val - 1
;
+ return
__hash_long(val - 1) % zs->nranges
;
}
void pareto_init(struct zipf_state *zs, unsigned long nranges, double h)
}
void pareto_init(struct zipf_state *zs, unsigned long nranges, double h)
@@
-142,5
+143,5
@@
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;
double rand = (double) __rand(&zs->rand) / (double) FRAND_MAX;
unsigned long long n = zs->nranges - 1;
- return
n * pow(rand, zs->pareto_pow)
;
+ return
__hash_long(n * pow(rand, zs->pareto_pow)) % zs->nranges
;
}
}