aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/test/perftest
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/messagebus/test/perftest
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/test/perftest')
-rw-r--r--library/cpp/messagebus/test/perftest/perftest.cpp130
-rw-r--r--library/cpp/messagebus/test/perftest/simple_proto.cpp4
-rw-r--r--library/cpp/messagebus/test/perftest/simple_proto.h24
3 files changed, 79 insertions, 79 deletions
diff --git a/library/cpp/messagebus/test/perftest/perftest.cpp b/library/cpp/messagebus/test/perftest/perftest.cpp
index 8489319278..8ce4c175a2 100644
--- a/library/cpp/messagebus/test/perftest/perftest.cpp
+++ b/library/cpp/messagebus/test/perftest/perftest.cpp
@@ -41,18 +41,18 @@ using namespace NBus;
const int DEFAULT_PORT = 55666;
struct TPerftestConfig {
- TString Nodes; ///< node1:port1,node2:port2
- int ClientCount;
- int MessageSize; ///< size of message to send
- int Delay; ///< server delay (milliseconds)
- float Failure; ///< simulated failure rate
- int ServerPort;
- int Run;
- bool ServerUseModules;
- bool ExecuteOnMessageInWorkerPool;
- bool ExecuteOnReplyInWorkerPool;
- bool UseCompression;
- bool Profile;
+ TString Nodes; ///< node1:port1,node2:port2
+ int ClientCount;
+ int MessageSize; ///< size of message to send
+ int Delay; ///< server delay (milliseconds)
+ float Failure; ///< simulated failure rate
+ int ServerPort;
+ int Run;
+ bool ServerUseModules;
+ bool ExecuteOnMessageInWorkerPool;
+ bool ExecuteOnReplyInWorkerPool;
+ bool UseCompression;
+ bool Profile;
unsigned WwwPort;
TPerftestConfig();
@@ -61,8 +61,8 @@ struct TPerftestConfig {
fprintf(stderr, "ClientCount=%d\n", ClientCount);
fprintf(stderr, "ServerPort=%d\n", ServerPort);
fprintf(stderr, "Delay=%d usecs\n", Delay);
- fprintf(stderr, "MessageSize=%d bytes\n", MessageSize);
- fprintf(stderr, "Failure=%.3f%%\n", Failure * 100.0);
+ fprintf(stderr, "MessageSize=%d bytes\n", MessageSize);
+ fprintf(stderr, "Failure=%.3f%%\n", Failure * 100.0);
fprintf(stderr, "Runtime=%d seconds\n", Run);
fprintf(stderr, "ServerUseModules=%s\n", ServerUseModules ? "true" : "false");
fprintf(stderr, "ExecuteOnMessageInWorkerPool=%s\n", ExecuteOnMessageInWorkerPool ? "true" : "false");
@@ -73,7 +73,7 @@ struct TPerftestConfig {
}
};
-extern TPerftestConfig* TheConfig;
+extern TPerftestConfig* TheConfig;
extern bool TheExit;
TVector<TNetAddr> ServerAddresses;
@@ -191,26 +191,26 @@ struct TTestStats {
TAtomic Errors;
TAtomic Replies;
- void IncMessage() {
- AtomicIncrement(Messages);
- }
- void IncReplies() {
- AtomicDecrement(Messages);
- AtomicIncrement(Replies);
- }
- int NumMessage() {
- return AtomicGet(Messages);
- }
- void IncErrors() {
- AtomicDecrement(Messages);
- AtomicIncrement(Errors);
- }
- int NumErrors() {
- return AtomicGet(Errors);
- }
- int NumReplies() {
- return AtomicGet(Replies);
- }
+ void IncMessage() {
+ AtomicIncrement(Messages);
+ }
+ void IncReplies() {
+ AtomicDecrement(Messages);
+ AtomicIncrement(Replies);
+ }
+ int NumMessage() {
+ return AtomicGet(Messages);
+ }
+ void IncErrors() {
+ AtomicDecrement(Messages);
+ AtomicIncrement(Errors);
+ }
+ int NumErrors() {
+ return AtomicGet(Errors);
+ }
+ int NumReplies() {
+ return AtomicGet(Replies);
+ }
double GetThroughput() {
return NumReplies() * 1000000.0 / (TInstant::Now() - Start).MicroSeconds();
@@ -232,7 +232,7 @@ TTestStats Stats;
////////////////////////////////////////////////////////////////////
/// \brief Fast of the client session
-class TPerftestClient : IBusClientHandler {
+class TPerftestClient : IBusClientHandler {
public:
TBusClientSessionPtr Session;
THolder<TBusProtocol> Proto;
@@ -270,7 +270,7 @@ public:
connection = Connections.at(RandomNumber<size_t>()).Get();
}
- TBusMessage* message = NewRequest().Release();
+ TBusMessage* message = NewRequest().Release();
int ret = connection->SendMessage(message, true);
if (ret == MESSAGE_OK) {
@@ -386,7 +386,7 @@ public:
CheckRequest(typed);
/// forget replies for few messages, see what happends
- if (TheConfig->Failure > RandomNumber<double>()) {
+ if (TheConfig->Failure > RandomNumber<double>()) {
return;
}
@@ -420,7 +420,7 @@ public:
Y_VERIFY(StartInput(), "failed to start input");
}
- ~TPerftestUsingModule() override {
+ ~TPerftestUsingModule() override {
Shutdown();
}
@@ -435,7 +435,7 @@ private:
}
/// forget replies for few messages, see what happends
- if (TheConfig->Failure > RandomNumber<double>()) {
+ if (TheConfig->Failure > RandomNumber<double>()) {
return nullptr;
}
@@ -454,15 +454,15 @@ using namespace std;
using namespace NBus;
static TNetworkAddress ParseNetworkAddress(const char* string) {
- TString Name;
- int Port;
+ TString Name;
+ int Port;
- const char* port = strchr(string, ':');
+ const char* port = strchr(string, ':');
if (port != nullptr) {
Name.append(string, port - string);
Port = atoi(port + 1);
- } else {
+ } else {
Name.append(string);
Port = TheConfig->ServerPort != 0 ? TheConfig->ServerPort : DEFAULT_PORT;
}
@@ -503,19 +503,19 @@ TPerftestConfig::TPerftestConfig() {
WwwPort = 0;
}
-TPerftestConfig* TheConfig = new TPerftestConfig();
-bool TheExit = false;
+TPerftestConfig* TheConfig = new TPerftestConfig();
+bool TheExit = false;
TSystemEvent StopEvent;
-TSimpleSharedPtr<TPerftestServer> Server;
-TSimpleSharedPtr<TPerftestUsingModule> ServerUsingModule;
+TSimpleSharedPtr<TPerftestServer> Server;
+TSimpleSharedPtr<TPerftestUsingModule> ServerUsingModule;
-TVector<TSimpleSharedPtr<TPerftestClient>> Clients;
+TVector<TSimpleSharedPtr<TPerftestClient>> Clients;
TMutex ClientsLock;
void stopsignal(int /*sig*/) {
- fprintf(stderr, "\n-------------------- exiting ------------------\n");
+ fprintf(stderr, "\n-------------------- exiting ------------------\n");
TheExit = true;
StopEvent.Signal();
}
@@ -531,22 +531,22 @@ void TTestStats::PeriodicallyPrint() {
if (TheExit)
break;
- TVector<TSimpleSharedPtr<TPerftestClient>> clients;
+ TVector<TSimpleSharedPtr<TPerftestClient>> clients;
{
TGuard<TMutex> guard(ClientsLock);
clients = Clients;
}
fprintf(stderr, "replies=%d errors=%d throughput=%.3f mess/sec\n",
- NumReplies(), NumErrors(), GetThroughput());
+ NumReplies(), NumErrors(), GetThroughput());
if (!!Server) {
fprintf(stderr, "server: q: %u %s\n",
- (unsigned)Server->Bus->GetExecutor()->GetWorkQueueSize(),
+ (unsigned)Server->Bus->GetExecutor()->GetWorkQueueSize(),
Server->Session->GetStatusSingleLine().data());
}
if (!!ServerUsingModule) {
fprintf(stderr, "server: q: %u %s\n",
- (unsigned)ServerUsingModule->Bus->GetExecutor()->GetWorkQueueSize(),
+ (unsigned)ServerUsingModule->Bus->GetExecutor()->GetWorkQueueSize(),
ServerUsingModule->Session->GetStatusSingleLine().data());
}
for (const auto& client : clients) {
@@ -587,19 +587,19 @@ void TTestStats::PeriodicallyPrint() {
}
}
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
NLWTrace::StartLwtraceFromEnv();
- /* unix foo */
+ /* unix foo */
setvbuf(stdout, nullptr, _IONBF, 0);
setvbuf(stderr, nullptr, _IONBF, 0);
Umask(0);
- SetAsyncSignalHandler(SIGINT, stopsignal);
+ SetAsyncSignalHandler(SIGINT, stopsignal);
SetAsyncSignalHandler(SIGTERM, stopsignal);
#ifndef _win_
SetAsyncSignalHandler(SIGUSR1, stopsignal);
#endif
- signal(SIGPIPE, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
NLastGetopt::TOpts opts = NLastGetopt::TOpts::Default();
opts.AddLongOption('s', "server-port", "server port").RequiredArgument("port").StoreResult(&TheConfig->ServerPort);
@@ -611,11 +611,11 @@ int main(int argc, char* argv[]) {
opts.AddLongOption("client-count", "amount of clients").RequiredArgument("count").StoreResult(&TheConfig->ClientCount).DefaultValue("1");
opts.AddLongOption("server-use-modules").StoreResult(&TheConfig->ServerUseModules, true);
opts.AddLongOption("on-message-in-pool", "execute OnMessage callback in worker pool")
- .RequiredArgument("BOOL")
- .StoreResult(&TheConfig->ExecuteOnMessageInWorkerPool);
+ .RequiredArgument("BOOL")
+ .StoreResult(&TheConfig->ExecuteOnMessageInWorkerPool);
opts.AddLongOption("on-reply-in-pool", "execute OnReply callback in worker pool")
- .RequiredArgument("BOOL")
- .StoreResult(&TheConfig->ExecuteOnReplyInWorkerPool);
+ .RequiredArgument("BOOL")
+ .StoreResult(&TheConfig->ExecuteOnReplyInWorkerPool);
opts.AddLongOption("compression", "use compression").RequiredArgument("BOOL").StoreResult(&TheConfig->UseCompression);
opts.AddLongOption("simple-proto").SetFlag(&Config.SimpleProtocol);
opts.AddLongOption("profile").SetFlag(&TheConfig->Profile);
@@ -651,8 +651,8 @@ int main(int argc, char* argv[]) {
www->RegisterServerSession(Server->Session);
}
}
-
- TVector<TSimpleSharedPtr<NThreading::TLegacyFuture<void, false>>> futures;
+
+ TVector<TSimpleSharedPtr<NThreading::TLegacyFuture<void, false>>> futures;
if (ServerAddresses.size() > 0 && TheConfig->ClientCount > 0) {
for (int i = 0; i < TheConfig->ClientCount; ++i) {
@@ -684,7 +684,7 @@ int main(int argc, char* argv[]) {
ServerUsingModule->Stop();
}
- TVector<TSimpleSharedPtr<TPerftestClient>> clients;
+ TVector<TSimpleSharedPtr<TPerftestClient>> clients;
{
TGuard<TMutex> guard(ClientsLock);
clients = Clients;
diff --git a/library/cpp/messagebus/test/perftest/simple_proto.cpp b/library/cpp/messagebus/test/perftest/simple_proto.cpp
index 19d6c15b9d..a54d4b3493 100644
--- a/library/cpp/messagebus/test/perftest/simple_proto.cpp
+++ b/library/cpp/messagebus/test/perftest/simple_proto.cpp
@@ -6,10 +6,10 @@
using namespace NBus;
-void TSimpleProtocol::Serialize(const TBusMessage* mess, TBuffer& data) {
+void TSimpleProtocol::Serialize(const TBusMessage* mess, TBuffer& data) {
Y_VERIFY(typeid(TSimpleMessage) == typeid(*mess));
const TSimpleMessage* typed = static_cast<const TSimpleMessage*>(mess);
- data.Append((const char*)&typed->Payload, 4);
+ data.Append((const char*)&typed->Payload, 4);
}
TAutoPtr<TBusMessage> TSimpleProtocol::Deserialize(ui16, TArrayRef<const char> payload) {
diff --git a/library/cpp/messagebus/test/perftest/simple_proto.h b/library/cpp/messagebus/test/perftest/simple_proto.h
index 4a0cc08db3..b61c4f4ae6 100644
--- a/library/cpp/messagebus/test/perftest/simple_proto.h
+++ b/library/cpp/messagebus/test/perftest/simple_proto.h
@@ -2,28 +2,28 @@
#include <library/cpp/messagebus/ybus.h>
-struct TSimpleMessage: public NBus::TBusMessage {
+struct TSimpleMessage: public NBus::TBusMessage {
ui32 Payload;
TSimpleMessage()
- : TBusMessage(1)
- , Payload(0)
- {
- }
+ : TBusMessage(1)
+ , Payload(0)
+ {
+ }
TSimpleMessage(NBus::ECreateUninitialized)
: TBusMessage(NBus::ECreateUninitialized())
- {
- }
+ {
+ }
};
struct TSimpleProtocol: public NBus::TBusProtocol {
- TSimpleProtocol()
- : NBus::TBusProtocol("simple", 55666)
- {
- }
+ TSimpleProtocol()
+ : NBus::TBusProtocol("simple", 55666)
+ {
+ }
- void Serialize(const NBus::TBusMessage* mess, TBuffer& data) override;
+ void Serialize(const NBus::TBusMessage* mess, TBuffer& data) override;
TAutoPtr<NBus::TBusMessage> Deserialize(ui16 ty, TArrayRef<const char> payload) override;
};