Skip to content

Commit d9e170d

Browse files
celery1124facebook-github-bot
authored andcommitted
Fix issues for reproducing synthetic ZippyDB workloads in the FAST20' paper (facebook#6795)
Summary: Fix issues for reproducing synthetic ZippyDB workloads in the FAST20' paper using db_bench. Details changes as follows. 1, add a separate random mode in MixGraph to produce all_random workload. 2, fix power inverse function for generating prefix_dist workload. 3, make sure key_offset in prefix mode is always unsigned. note: Need to carefully choose key_dist_a/b to avoid aliasing. Power inverse function range should be close to overall key space. Pull Request resolved: facebook#6795 Reviewed By: akankshamahajan15 Differential Revision: D21371095 Pulled By: zhichao-cao fbshipit-source-id: 80744381e242392c8c7cf8ac3d68fe67fe876048
1 parent 211088d commit d9e170d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tools/db_bench_tool.cc

+12-4
Original file line numberDiff line numberDiff line change
@@ -5415,13 +5415,15 @@ class Benchmark {
54155415

54165416
// Select one key in the key-range and compose the keyID
54175417
int64_t key_offset = 0, key_seed;
5418-
if (key_dist_a == 0.0 && key_dist_b == 0.0) {
5418+
if (key_dist_a == 0.0 || key_dist_b == 0.0) {
54195419
key_offset = ini_rand % keyrange_size_;
54205420
} else {
5421+
double u =
5422+
static_cast<double>(ini_rand % keyrange_size_) / keyrange_size_;
54215423
key_seed = static_cast<int64_t>(
5422-
ceil(std::pow((ini_rand / key_dist_a), (1 / key_dist_b))));
5424+
ceil(std::pow((u / key_dist_a), (1 / key_dist_b))));
54235425
Random64 rand_key(key_seed);
5424-
key_offset = static_cast<int64_t>(rand_key.Next()) % keyrange_size_;
5426+
key_offset = rand_key.Next() % keyrange_size_;
54255427
}
54265428
return keyrange_size_ * keyrange_id + key_offset;
54275429
}
@@ -5448,6 +5450,7 @@ class Benchmark {
54485450
double write_rate = 1000000.0;
54495451
double read_rate = 1000000.0;
54505452
bool use_prefix_modeling = false;
5453+
bool use_random_modeling = false;
54515454
GenerateTwoTermExpKeys gen_exp;
54525455
std::vector<double> ratio{FLAGS_mix_get_ratio, FLAGS_mix_put_ratio,
54535456
FLAGS_mix_seek_ratio};
@@ -5482,6 +5485,9 @@ class Benchmark {
54825485
FLAGS_num, FLAGS_keyrange_dist_a, FLAGS_keyrange_dist_b,
54835486
FLAGS_keyrange_dist_c, FLAGS_keyrange_dist_d);
54845487
}
5488+
if (FLAGS_key_dist_a == 0 || FLAGS_key_dist_b == 0) {
5489+
use_random_modeling = true;
5490+
}
54855491

54865492
Duration duration(FLAGS_duration, reads_);
54875493
while (!duration.Done(1)) {
@@ -5492,7 +5498,9 @@ class Benchmark {
54925498
double u = static_cast<double>(rand_v) / FLAGS_num;
54935499

54945500
// Generate the keyID based on the key hotness and prefix hotness
5495-
if (use_prefix_modeling) {
5501+
if (use_random_modeling) {
5502+
key_rand = ini_rand;
5503+
} else if (use_prefix_modeling) {
54965504
key_rand =
54975505
gen_exp.DistGetKeyID(ini_rand, FLAGS_key_dist_a, FLAGS_key_dist_b);
54985506
} else {

0 commit comments

Comments
 (0)