Skip to content

Commit

Permalink
fix 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GehaFearless committed Mar 1, 2023
1 parent 7ddb15c commit d794cfb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,7 @@ function usage_bench()
echo " --value_size <num> value size in bytes, default is 100"
echo " --timeout <num> timeout in milliseconds, default is 1000"
echo " --seed <num> seed base for random number generator, When 0 it is specified as 1000. default is 1000"
echo " --multi_count <num> values count of the same hashkey, used by multi_set/multi_get, default is 100"
}

function fill_bench_config() {
Expand Down
23 changes: 13 additions & 10 deletions src/test/bench_test/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DSN_DECLARE_int32(pegasus_timeout_ms);
DSN_DECLARE_int32(sortkey_size);
DSN_DECLARE_int32(threads);
DSN_DECLARE_int32(value_size);
DSN_DECLARE_int32(multi_count);

benchmark::benchmark()
{
Expand Down Expand Up @@ -159,14 +160,14 @@ void benchmark::multi_set_random(thread_arg *thread)
// do write operation num times
uint64_t bytes = 0;

for (int i = 0; i < FLAGS_benchmark_num / 100; i++) {
for (int i = 0; i < FLAGS_benchmark_num / FLAGS_multi_count; i++) {
// generate hash key
std::string hash_key, sort_key, value;
hash_key = generate_string(FLAGS_hashkey_size);
std::map<std::string, std::string> kvs;

// generate sort key and value
for (int j = 0; j < 100; j++) {
for (int j = 0; j < FLAGS_multi_count; j++) {
sort_key = generate_string(FLAGS_sortkey_size);
value = generate_string(FLAGS_value_size);
kvs.emplace(sort_key, value);
Expand All @@ -178,7 +179,7 @@ void benchmark::multi_set_random(thread_arg *thread)
try_count++;
int ret = _client->multi_set(hash_key, kvs, FLAGS_pegasus_timeout_ms);
if (ret == ::pegasus::PERR_OK) {
bytes += (FLAGS_value_size + FLAGS_hashkey_size + FLAGS_sortkey_size) * 100;
bytes += (FLAGS_value_size + FLAGS_hashkey_size + FLAGS_sortkey_size) * FLAGS_multi_count;
break;
} else if (ret != ::pegasus::PERR_TIMEOUT || try_count > 3) {
fmt::print(stderr, "Set returned an error: {}\n", _client->get_error_string(ret));
Expand Down Expand Up @@ -242,17 +243,16 @@ void benchmark::multi_get_random(thread_arg *thread)
int max_fetch_count = 100;
int max_fetch_size = 1000000;

for (int i = 0; i < FLAGS_benchmark_num / 100; i++) {

for (int i = 0; i < FLAGS_benchmark_num / FLAGS_multi_count; i++) {
// generate hash key
std::string hashkey, sort_key, value;
std::string hashkey, value;
hashkey = generate_string(FLAGS_hashkey_size);
std::map<std::string, std::string> kvs;
std::set<std::string> sortkeys;

// generate sort key
// generate value for random to keep in peace with write
for (int j = 0; j < 100; j++) {
for (int j = 0; j < FLAGS_multi_count; j++) {
sortkeys.insert(generate_string(FLAGS_sortkey_size));
value = generate_string(FLAGS_value_size);
}
Expand All @@ -264,8 +264,11 @@ void benchmark::multi_get_random(thread_arg *thread)
int ret = _client->multi_get(
hashkey, sortkeys, kvs, max_fetch_count, max_fetch_size, FLAGS_pegasus_timeout_ms);
if (ret == ::pegasus::PERR_OK) {
found += 100;
bytes += (FLAGS_hashkey_size + FLAGS_sortkey_size + FLAGS_value_size) * 100;
found += FLAGS_multi_count;
bytes += FLAGS_multi_count * hashkey.size();
for (auto &kv : kvs) {
bytes = kv.first.size() + kv.second.size() + bytes;
}
break;
} else if (ret == ::pegasus::PERR_NOT_FOUND) {
break;
Expand All @@ -278,7 +281,7 @@ void benchmark::multi_get_random(thread_arg *thread)
}

// count this operation
thread->stats.finished_ops(1, kRead);
thread->stats.finished_ops(1, kMultiGet);
}

// count total read bytes and hit rate
Expand Down
1 change: 1 addition & 0 deletions src/test/bench_test/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ DSN_DEFINE_int32(pegasus.benchmark, threads, 1, "Number of concurrent threads to
DSN_DEFINE_int32(pegasus.benchmark, hashkey_size, 16, "size of each hashkey");
DSN_DEFINE_int32(pegasus.benchmark, sortkey_size, 16, "size of each sortkey");
DSN_DEFINE_int32(pegasus.benchmark, value_size, 100, "Size of each value");
DSN_DEFINE_int32(pegasus.benchmark, multi_count, 100, "Values count of the same hashkey");

config::config()
{
Expand Down
1 change: 1 addition & 0 deletions src/test/bench_test/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ value_size = @VALUE_SIZE@
hashkey_size = @HASHKEY_SIZE@
sortkey_size = @SORTKEY_SIZE@
benchmark_seed = @SEED@
multi_count = @MULTI_COUNT@

4 changes: 2 additions & 2 deletions src/test/bench_test/statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ std::unordered_map<operation_type, std::string, std::hash<unsigned char>> operat
{kRead, "read"},
{kWrite, "write"},
{kDelete, "delete"},
{kMultiSet, "multiset"},
{kMultiGet, "multiget"}};
{kMultiSet, "multiSet"},
{kMultiGet, "multiGet"}};

statistics::statistics(std::shared_ptr<rocksdb::Statistics> hist_stats)
{
Expand Down

0 comments on commit d794cfb

Please sign in to comment.