From 8f61d260076fcf56da4dc73ac67bc131aae0d8d7 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 23 Jan 2025 18:51:37 +0300 Subject: [PATCH] test/perf/s3: Add --part-size-mb option for upload test Test now uses default internal part size, but for performance comparisons its good to make it configurable. Signed-off-by: Pavel Emelyanov --- test/perf/perf_s3_client.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/perf/perf_s3_client.cc b/test/perf/perf_s3_client.cc index c8afabd970..86bd38e030 100644 --- a/test/perf/perf_s3_client.cc +++ b/test/perf/perf_s3_client.cc @@ -26,6 +26,7 @@ class tester { shared_ptr _client; utils::estimated_histogram _latencies; unsigned _errors = 0; + unsigned _part_size_mb; bool _remove_file; static s3::endpoint_config_ptr make_config(unsigned sockets) { @@ -43,12 +44,13 @@ class tester { std::chrono::steady_clock::time_point now() const { return std::chrono::steady_clock::now(); } public: - tester(std::chrono::seconds dur, unsigned sockets, sstring object_name, size_t obj_size) + tester(std::chrono::seconds dur, unsigned sockets, unsigned part_size, sstring object_name, size_t obj_size) : _duration(dur) , _object_name(std::move(object_name)) , _object_size(obj_size) , _mem(memory::stats().total_memory()) , _client(s3::client::make(tests::getenv_safe("S3_SERVER_ADDRESS_FOR_TEST"), make_config(sockets), _mem)) + , _part_size_mb(part_size) , _remove_file(false) {} @@ -108,7 +110,7 @@ public: _object_name = fmt::format("/{}/{}", tests::getenv_safe("S3_BUCKET_FOR_TEST"), file_name.filename().native()); _remove_file = true; auto start = now(); - co_await _client->upload_file(file_name, _object_name); + co_await _client->upload_file(file_name, _object_name, {}, _part_size_mb << 20); auto time = std::chrono::duration_cast>(now() - start); plog.info("Uploaded {}MB in {}s, speed {}MB/s", sz >> 20, time.count(), (sz >> 20) / time.count()); } @@ -141,6 +143,7 @@ int main(int argc, char** argv) { ("upload", "test file upload") ("duration", bpo::value()->default_value(10), "seconds to run") ("sockets", bpo::value()->default_value(1), "maximum number of socket for http client") + ("part_size_mb", bpo::value()->default_value(5), "part size") ("object_name", bpo::value()->default_value(""), "use given object/file name") ("object_size", bpo::value()->default_value(1 << 20), "size of test object") ; @@ -148,12 +151,13 @@ int main(int argc, char** argv) { return app.run(argc, argv, [&app] () -> future<> { auto dur = std::chrono::seconds(app.configuration()["duration"].as()); auto sks = app.configuration()["sockets"].as(); + auto part_size = app.configuration()["part_size_mb"].as(); auto oname = app.configuration()["object_name"].as(); auto osz = app.configuration()["object_size"].as(); auto upload = app.configuration().contains("upload"); sharded test; plog.info("Creating"); - co_await test.start(dur, sks, oname, osz); + co_await test.start(dur, sks, part_size, oname, osz); plog.info("Starting"); co_await test.invoke_on_all(&tester::start); try {