acelyc111 commented on code in PR #1373:
URL:
https://github.com/apache/incubator-pegasus/pull/1373#discussion_r1121332357
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -152,6 +155,57 @@ void benchmark::write_random(thread_arg *thread)
thread->stats.add_bytes(bytes);
}
+void benchmark::multi_set_random(thread_arg *thread)
+{
+ if (FLAGS_benchmark_num % FLAGS_multi_count != 0) {
Review Comment:
Use `DSN_DEFINE_group_validator` to check flags.
##########
src/test/bench_test/config.cpp:
##########
@@ -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");
Review Comment:
Could you plz move all the configs (all DSN_DEFINE_*) to file
`src/test/bench_test/benchmark.cpp`, where is closer to the place use them?
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -152,6 +155,57 @@ void benchmark::write_random(thread_arg *thread)
thread->stats.add_bytes(bytes);
}
+void benchmark::multi_set_random(thread_arg *thread)
+{
+ if (FLAGS_benchmark_num % FLAGS_multi_count != 0) {
+ fmt::print(stderr,
+ "num {} should be a multiple of multi_count({}).\n",
+ FLAGS_benchmark_num,
+ FLAGS_multi_count);
+ dsn_exit(1);
+ }
+
+ // do write operation num times
+ uint64_t bytes = 0;
+
+ 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 < FLAGS_multi_count; j++) {
+ sort_key = generate_string(FLAGS_sortkey_size);
+ value = generate_string(FLAGS_value_size);
+ kvs.emplace(sort_key, value);
+ }
+
+ // write to pegasus
+ int try_count = 0;
+ while (true) {
+ 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) *
+ 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));
+ dsn_exit(1);
+ } else {
Review Comment:
Then
```suggestion
}
```
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -152,6 +155,57 @@ void benchmark::write_random(thread_arg *thread)
thread->stats.add_bytes(bytes);
}
+void benchmark::multi_set_random(thread_arg *thread)
+{
+ if (FLAGS_benchmark_num % FLAGS_multi_count != 0) {
+ fmt::print(stderr,
+ "num {} should be a multiple of multi_count({}).\n",
+ FLAGS_benchmark_num,
+ FLAGS_multi_count);
+ dsn_exit(1);
+ }
+
+ // do write operation num times
Review Comment:
For comments, it's recommend to use upper case for the leading letter, and
ended by a dot.
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -191,6 +235,58 @@ void benchmark::read_random(thread_arg *thread)
thread->stats.add_message(msg);
}
+void benchmark::multi_get_random(thread_arg *thread)
+{
+ uint64_t bytes = 0;
+ uint64_t found = 0;
+ int max_fetch_count = 100;
+ int max_fetch_size = 1000000;
+
+ for (int i = 0; i < FLAGS_benchmark_num / 100; i++) {
+
+ // generate hash key
+ std::string hashkey, sort_key, 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++) {
+ sortkeys.insert(generate_string(FLAGS_sortkey_size));
+ value = generate_string(FLAGS_value_size);
Review Comment:
Invoke `generate_string` is enough, not need to assign, and add some
comments.
PS: A better way is to separate the generator function of keys and values.
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -152,6 +155,57 @@ void benchmark::write_random(thread_arg *thread)
thread->stats.add_bytes(bytes);
}
+void benchmark::multi_set_random(thread_arg *thread)
+{
+ if (FLAGS_benchmark_num % FLAGS_multi_count != 0) {
+ fmt::print(stderr,
+ "num {} should be a multiple of multi_count({}).\n",
+ FLAGS_benchmark_num,
+ FLAGS_multi_count);
+ dsn_exit(1);
+ }
+
+ // do write operation num times
+ uint64_t bytes = 0;
+
+ 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 < FLAGS_multi_count; j++) {
+ sort_key = generate_string(FLAGS_sortkey_size);
+ value = generate_string(FLAGS_value_size);
+ kvs.emplace(sort_key, value);
+ }
+
+ // write to pegasus
+ int try_count = 0;
+ while (true) {
+ 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) *
+ 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));
+ dsn_exit(1);
+ } else {
Review Comment:
The same to multi_get_random.
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -152,6 +155,57 @@ void benchmark::write_random(thread_arg *thread)
thread->stats.add_bytes(bytes);
}
+void benchmark::multi_set_random(thread_arg *thread)
+{
+ if (FLAGS_benchmark_num % FLAGS_multi_count != 0) {
+ fmt::print(stderr,
+ "num {} should be a multiple of multi_count({}).\n",
+ FLAGS_benchmark_num,
+ FLAGS_multi_count);
+ dsn_exit(1);
+ }
+
+ // do write operation num times
+ uint64_t bytes = 0;
+
+ 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 < FLAGS_multi_count; j++) {
+ sort_key = generate_string(FLAGS_sortkey_size);
+ value = generate_string(FLAGS_value_size);
+ kvs.emplace(sort_key, value);
+ }
+
+ // write to pegasus
+ int try_count = 0;
+ while (true) {
+ 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) *
+ FLAGS_multi_count;
+ break;
+ } else if (ret != ::pegasus::PERR_TIMEOUT || try_count > 3) {
Review Comment:
```suggestion
}
if (ret != ::pegasus::PERR_TIMEOUT || try_count > 3) {
```
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -152,6 +155,57 @@ void benchmark::write_random(thread_arg *thread)
thread->stats.add_bytes(bytes);
}
+void benchmark::multi_set_random(thread_arg *thread)
+{
+ if (FLAGS_benchmark_num % FLAGS_multi_count != 0) {
+ fmt::print(stderr,
+ "num {} should be a multiple of multi_count({}).\n",
+ FLAGS_benchmark_num,
+ FLAGS_multi_count);
+ dsn_exit(1);
+ }
+
+ // do write operation num times
+ uint64_t bytes = 0;
+
+ 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);
Review Comment:
Define and assign hash_key in one line.
`sort_key` and `value` are not needed to declare here, you can emplace the
generated strings to kvs directly, i.e. `kvs.emplace(generate_string(...),
generate_string(...));`.
##########
src/test/bench_test/benchmark.cpp:
##########
@@ -152,6 +154,48 @@ void benchmark::write_random(thread_arg *thread)
thread->stats.add_bytes(bytes);
}
+void benchmark::multi_set_random(thread_arg *thread)
+{
+ // do write operation num times
Review Comment:
Use `FLAGS_benchmark_num` to replace it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]