From ce63da01f6fb20eb6bd4177186f5111e20f98f73 Mon Sep 17 00:00:00 2001 From: Amaury Chamayou Date: Tue, 8 Dec 2020 13:43:07 +0000 Subject: [PATCH] JS logging perf test (#1987) --- CMakeLists.txt | 23 +++++++++++++++++++++++ src/perf_client/perf_client.h | 21 +++++++++++++++++++++ src/perf_client/scenario_perf_client.cpp | 12 +++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 863a3651d1..b18ed30128 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -840,6 +840,8 @@ if(BUILD_TESTS) 1000 --repetitions 1000 + --msg-ser-fmt + msgpack ) add_perf_test( @@ -858,6 +860,27 @@ if(BUILD_TESTS) --repetitions 10000 --use-websockets + --msg-ser-fmt + msgpack + ) + + add_perf_test( + NAME logging_scenario_js_perf_test + PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/perfclient.py + CONSENSUS cft + CLIENT_BIN ./scenario_perf_client + LABEL log_scenario_js + ADDITIONAL_ARGS + --js-app-bundle + ${CMAKE_SOURCE_DIR}/samples/apps/logging/js + --scenario-file + ${CMAKE_CURRENT_LIST_DIR}/tests/perf_logging_scenario_100txs.json + --max-writes-ahead + 1000 + --repetitions + 800 + --msg-ser-fmt + text ) endif() diff --git a/src/perf_client/perf_client.h b/src/perf_client/perf_client.h index 1ae29be962..1444c550ec 100644 --- a/src/perf_client/perf_client.h +++ b/src/perf_client/perf_client.h @@ -350,6 +350,27 @@ namespace client append_prepared_tx(tx, index); } + void add_prepared_tx( + const std::string& method, + const nlohmann::json& params, + bool expects_commit, + const std::optional& index, + const serdes::Pack& serdes) + { + auto body = serdes::pack(params, serdes); + + const PreparedTx tx{rpc_connection->gen_request( + method, + body, + serdes == serdes::Pack::Text ? + http::headervalues::contenttype::OCTET_STREAM : + http::headervalues::contenttype::MSGPACK), + method, + expects_commit}; + + append_prepared_tx(tx, index); + } + void add_prepared_tx( const std::string& method, const nlohmann::json& params, diff --git a/src/perf_client/scenario_perf_client.cpp b/src/perf_client/scenario_perf_client.cpp index 5c14103fa1..3a93a2acd4 100644 --- a/src/perf_client/scenario_perf_client.cpp +++ b/src/perf_client/scenario_perf_client.cpp @@ -10,6 +10,9 @@ struct ScenarioPerfClientOptions : public client::PerfOptions { size_t repetitions = 1; std::string scenario_file; + std::vector> serdes_map{ + {"text", serdes::Pack::Text}, {"msgpack", serdes::Pack::MsgPack}}; + serdes::Pack serdes; ScenarioPerfClientOptions( CLI::App& app, const std::string& default_pid_file) : @@ -19,6 +22,9 @@ struct ScenarioPerfClientOptions : public client::PerfOptions app.add_option("--scenario-file", scenario_file) ->required(true) ->check(CLI::ExistingFile); + app.add_option("--msg-ser-fmt", serdes, "Message serialisation format") + ->required() + ->transform(CLI::CheckedTransformer(serdes_map, CLI::ignore_case)); } }; @@ -107,7 +113,11 @@ private: const auto& transaction = transactions[i]; add_prepared_tx( - transaction["method"], transaction["params"], true, std::nullopt); + transaction["method"], + transaction["params"], + true, + std::nullopt, + options.serdes); } } }