From b2405a7251d7eda2043538bb59f69b97da3aef02 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Thu, 17 Aug 2023 11:28:37 +0800 Subject: [PATCH] crimson/tools/perf_crimson_msgr: randomize client nonce In case we want to start multiple clients simultaneously. Signed-off-by: Yingxin Cheng (cherry picked from commit 91c65e22387aa4b7c572712f4a3028ed6e8d40f9) --- src/crimson/tools/perf_crimson_msgr.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/crimson/tools/perf_crimson_msgr.cc b/src/crimson/tools/perf_crimson_msgr.cc index 1e4bde97dac5f..0dadc7ceb8a8a 100644 --- a/src/crimson/tools/perf_crimson_msgr.cc +++ b/src/crimson/tools/perf_crimson_msgr.cc @@ -2,7 +2,6 @@ // vim: ts=8 sw=2 smarttab #include -#include #include #include @@ -18,6 +17,7 @@ #include "common/ceph_time.h" #include "messages/MOSDOp.h" +#include "include/random.h" #include "crimson/auth/DummyAuth.h" #include "crimson/common/log.h" @@ -575,6 +575,7 @@ static seastar::future<> run( const unsigned msg_len; bufferlist msg_data; const unsigned nr_depth; + const unsigned nonce_base; crimson::auth::DummyAuthClientServer dummy_auth; std::vector conn_states; @@ -583,6 +584,7 @@ static seastar::future<> run( unsigned num_conns, unsigned msg_len, unsigned _depth, + unsigned nonce_base, std::optional server_sid) : sid{seastar::this_shard_id()}, id{sid + num_clients - seastar::smp::count}, @@ -590,7 +592,8 @@ static seastar::future<> run( num_clients{num_clients}, num_conns{num_conns}, msg_len{msg_len}, - nr_depth{_depth} { + nr_depth{_depth}, + nonce_base{nonce_base} { if (is_active()) { for (unsigned i = 0; i < num_conns; ++i) { conn_states.emplace_back(nr_depth); @@ -660,7 +663,7 @@ static seastar::future<> run( std::string name = client.get_name(i); conn_state.msgr = crimson::net::Messenger::create( entity_name_t::OSD(client.id * client.num_conns + i), - name, client.id * client.num_conns + i, true); + name, client.nonce_base + client.id * client.num_conns + i, true); conn_state.msgr->set_default_policy(crimson::net::SocketPolicy::lossy_client(0)); conn_state.msgr->set_auth_client(&client.dummy_auth); conn_state.msgr->set_auth_server(&client.dummy_auth); @@ -1085,11 +1088,14 @@ static seastar::future<> run( if (mode == perf_mode_t::server) { return seastar::make_ready_future(nullptr); } else { + unsigned nonce_base = ceph::util::generate_random_number(); + logger().info("client nonce_base={}", nonce_base); return create_sharded( client_conf.num_clients, client_conf.num_conns, client_conf.block_size, client_conf.depth, + nonce_base, server_sid); } }), -- 2.39.5