Adding required changes

pull/2151/head
Siddharth Rakesh 10 years ago
parent 66ebce4a61
commit 268e59063a
  1. 65
      test/cpp/qps/perf_db.proto
  2. 98
      test/cpp/qps/perf_db_client.cc
  3. 48
      test/cpp/qps/perf_db_client.h
  4. 72
      test/cpp/qps/report.cc
  5. 16
      test/cpp/qps/report.h

@ -35,14 +35,12 @@ package grpc.testing;
service PerfDbTransfer { service PerfDbTransfer {
// Sends client info // Sends client info
rpc RecordSingleClientData (SingleUserRecordRequest) returns (SingleUserRecordReply) {} rpc RecordSingleClientData(SingleUserRecordRequest)
returns (SingleUserRecordReply) {
rpc RetrieveSingleUserData (SingleUserRetrieveRequest) returns (SingleUserRetrieveReply) {} }
rpc RetrieveAllUsersData (AllUsersRetrieveRequest) returns (AllUsersRetrieveReply) {}
} }
//Metrics to be stored // Metrics to be stored
message Metrics { message Metrics {
double qps = 1; double qps = 1;
double qps_per_core = 2; double qps_per_core = 2;
@ -57,39 +55,7 @@ message Metrics {
double client_user_time = 11; double client_user_time = 11;
} }
//Timestamped details // Request for storing a single user's data
message DataDetails {
string timestamp = 1;
string test_name = 2;
string sys_info = 3;
string tag = 4;
Metrics metrics = 5;
ClientConfig client_config = 6;
ServerConfig server_config = 7;
}
//User details
message UserDetails {
string id = 1;
string email = 2;
bool verified_email = 3;
string name = 4;
string given_name = 5;
string family_name = 6;
string link = 7;
string picture = 8;
string gender = 9;
string locale = 10;
string hd = 11;
}
//Stored to database
message SingleUserDetails {
repeated DataDetails data_details = 1;
UserDetails user_details = 2;
}
//Request for storing a single user's data
message SingleUserRecordRequest { message SingleUserRecordRequest {
string access_token = 1; string access_token = 1;
string test_name = 2; string test_name = 2;
@ -100,25 +66,6 @@ message SingleUserRecordRequest {
ServerConfig server_config = 7; ServerConfig server_config = 7;
} }
//Reply to request for storing single user's data // Reply to request for storing single user's data
message SingleUserRecordReply { message SingleUserRecordReply {
} }
//Request for retrieving single user's data
message SingleUserRetrieveRequest {
string user_id = 1;
}
//Reply for request to retrieve single user's data
message SingleUserRetrieveReply {
SingleUserDetails details = 1;
}
//Request for retrieving all users' data
message AllUsersRetrieveReply {
repeated SingleUserDetails user_data = 1;
}
//Reply to request for retrieving all users' data
message AllUsersRetrieveRequest {
}

@ -36,25 +36,27 @@
namespace grpc { namespace grpc {
namespace testing { namespace testing {
//sets the client and server config information // sets the client and server config information
void PerfDbClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) { void PerfDbClient::setConfigs(const ClientConfig& clientConfig,
const ServerConfig& serverConfig) {
this->clientConfig_ = clientConfig; this->clientConfig_ = clientConfig;
this->serverConfig_ = serverConfig; this->serverConfig_ = serverConfig;
} }
//sets the QPS // sets the QPS
void PerfDbClient::setQPS(double QPS) { void PerfDbClient::setQPS(double QPS) { this->QPS_ = QPS; }
this->QPS_ = QPS;
}
//sets the QPS per core // sets the QPS per core
void PerfDbClient::setQPSPerCore(double QPSPerCore) { void PerfDbClient::setQPSPerCore(double QPSPerCore) {
this->QPSPerCore_ = QPSPerCore; this->QPSPerCore_ = QPSPerCore;
} }
//sets the 50th, 90th, 95th, 99th and 99.9th percentile latency // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency
void PerfDbClient::setLatencies(double percentileLatency50, double percentileLatency90, void PerfDbClient::setLatencies(double percentileLatency50,
double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) { double percentileLatency90,
double percentileLatency95,
double percentileLatency99,
double percentileLatency99Point9) {
this->percentileLatency50_ = percentileLatency50; this->percentileLatency50_ = percentileLatency50;
this->percentileLatency90_ = percentileLatency90; this->percentileLatency90_ = percentileLatency90;
this->percentileLatency95_ = percentileLatency95; this->percentileLatency95_ = percentileLatency95;
@ -62,54 +64,78 @@ void PerfDbClient::setLatencies(double percentileLatency50, double percentileLat
this->percentileLatency99Point9_ = percentileLatency99Point9; this->percentileLatency99Point9_ = percentileLatency99Point9;
} }
//sets the server and client, user and system times // sets the server and client, user and system times
void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime, void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime,
double clientSystemTime, double clientUserTime) { double clientSystemTime, double clientUserTime) {
this->serverSystemTime_ = serverSystemTime; this->serverSystemTime_ = serverSystemTime;
this->serverUserTime_ = serverUserTime; this->serverUserTime_ = serverUserTime;
this->clientSystemTime_ = clientSystemTime; this->clientSystemTime_ = clientSystemTime;
this->clientUserTime_ = clientUserTime; this->clientUserTime_ = clientUserTime;
} }
//sends the data to the performancew database server // sends the data to the performance database server
int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag) { bool PerfDbClient::sendData(std::string access_token, std::string test_name,
//Data record request object std::string sys_info, std::string tag) {
// Data record request object
SingleUserRecordRequest singleUserRecordRequest; SingleUserRecordRequest singleUserRecordRequest;
//setting access token, name of the test and the system information // setting access token, name of the test and the system information
singleUserRecordRequest.set_access_token(access_token); singleUserRecordRequest.set_access_token(access_token);
singleUserRecordRequest.set_test_name(test_name); singleUserRecordRequest.set_test_name(test_name);
singleUserRecordRequest.set_sys_info(sys_info); singleUserRecordRequest.set_sys_info(sys_info);
singleUserRecordRequest.set_tag(tag); singleUserRecordRequest.set_tag(tag);
//setting configs // setting configs
*(singleUserRecordRequest.mutable_client_config()) = this->clientConfig_; *(singleUserRecordRequest.mutable_client_config()) = this->clientConfig_;
*(singleUserRecordRequest.mutable_server_config()) = this->serverConfig_; *(singleUserRecordRequest.mutable_server_config()) = this->serverConfig_;
Metrics* metrics = singleUserRecordRequest.mutable_metrics(); Metrics* metrics = singleUserRecordRequest.mutable_metrics();
//setting metrcs in data record request // setting metrcs in data record request
if(QPS_ != DBL_MIN) metrics->set_qps(this->QPS_); if (QPS_ != DBL_MIN) {
if(QPSPerCore_ != DBL_MIN) metrics->set_qps_per_core(this->QPSPerCore_); metrics->set_qps(this->QPS_);
if(percentileLatency50_ != DBL_MIN) metrics->set_perc_lat_50(this->percentileLatency50_); }
if(percentileLatency90_ != DBL_MIN) metrics->set_perc_lat_90(this->percentileLatency90_); if (QPSPerCore_ != DBL_MIN) {
if(percentileLatency95_ != DBL_MIN) metrics->set_perc_lat_95(this->percentileLatency95_); metrics->set_qps_per_core(this->QPSPerCore_);
if(percentileLatency99_ != DBL_MIN) metrics->set_perc_lat_99(this->percentileLatency99_); }
if(percentileLatency99Point9_ != DBL_MIN) metrics->set_perc_lat_99_point_9(this->percentileLatency99Point9_); if (percentileLatency50_ != DBL_MIN) {
if(serverSystemTime_ != DBL_MIN) metrics->set_server_system_time(this->serverSystemTime_); metrics->set_perc_lat_50(this->percentileLatency50_);
if(serverUserTime_ != DBL_MIN) metrics->set_server_user_time(this->serverUserTime_); }
if(clientSystemTime_ != DBL_MIN) metrics->set_client_system_time(this->clientSystemTime_); if (percentileLatency90_ != DBL_MIN) {
if(clientUserTime_ != DBL_MIN) metrics->set_client_user_time(this->clientUserTime_); metrics->set_perc_lat_90(this->percentileLatency90_);
}
if (percentileLatency95_ != DBL_MIN) {
metrics->set_perc_lat_95(this->percentileLatency95_);
}
if (percentileLatency99_ != DBL_MIN) {
metrics->set_perc_lat_99(this->percentileLatency99_);
}
if (percentileLatency99Point9_ != DBL_MIN) {
metrics->set_perc_lat_99_point_9(this->percentileLatency99Point9_);
}
if (serverSystemTime_ != DBL_MIN) {
metrics->set_server_system_time(this->serverSystemTime_);
}
if (serverUserTime_ != DBL_MIN) {
metrics->set_server_user_time(this->serverUserTime_);
}
if (clientSystemTime_ != DBL_MIN) {
metrics->set_client_system_time(this->clientSystemTime_);
}
if (clientUserTime_ != DBL_MIN) {
metrics->set_client_user_time(this->clientUserTime_);
}
SingleUserRecordReply singleUserRecordReply; SingleUserRecordReply singleUserRecordReply;
ClientContext context; ClientContext context;
Status status = stub_->RecordSingleClientData(&context, singleUserRecordRequest, &singleUserRecordReply); Status status = stub_->RecordSingleClientData(
&context, singleUserRecordRequest, &singleUserRecordReply);
if (status.ok()) { if (status.ok()) {
return 1; //data sent to database successfully return true; // data sent to database successfully
} else { } else {
return -1; //error in data sending return false; // error in data sending
} }
} }
} //testing } // testing
} //grpc } // grpc

@ -45,13 +45,12 @@
#include <grpc++/status.h> #include <grpc++/status.h>
#include "test/cpp/qps/perf_db.grpc.pb.h" #include "test/cpp/qps/perf_db.grpc.pb.h"
namespace grpc {
namespace grpc{
namespace testing { namespace testing {
//Manages data sending to performance database server // Manages data sending to performance database server
class PerfDbClient { class PerfDbClient {
public: public:
PerfDbClient() { PerfDbClient() {
QPS_ = DBL_MIN; QPS_ = DBL_MIN;
QPSPerCore_ = DBL_MIN; QPSPerCore_ = DBL_MIN;
@ -65,32 +64,37 @@ public:
clientSystemTime_ = DBL_MIN; clientSystemTime_ = DBL_MIN;
clientUserTime_ = DBL_MIN; clientUserTime_ = DBL_MIN;
} }
void init(std::shared_ptr<ChannelInterface> channel) { stub_ = PerfDbTransfer::NewStub(channel); } void init(std::shared_ptr<ChannelInterface> channel) {
stub_ = PerfDbTransfer::NewStub(channel);
}
~PerfDbClient() {} ~PerfDbClient() {}
//sets the client and server config information // sets the client and server config information
void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig); void setConfigs(const ClientConfig& clientConfig,
const ServerConfig& serverConfig);
//sets the QPS
// sets the QPS
void setQPS(double QPS); void setQPS(double QPS);
//sets the QPS per core // sets the QPS per core
void setQPSPerCore(double QPSPerCore); void setQPSPerCore(double QPSPerCore);
//sets the 50th, 90th, 95th, 99th and 99.9th percentile latency // sets the 50th, 90th, 95th, 99th and 99.9th percentile latency
void setLatencies(double percentileLatency50, double percentileLatency90, void setLatencies(double percentileLatency50, double percentileLatency90,
double percentileLatency95, double percentileLatency99, double percentileLatency99Point9); double percentileLatency95, double percentileLatency99,
double percentileLatency99Point9);
//sets the server and client, user and system times // sets the server and client, user and system times
void setTimes(double serverSystemTime, double serverUserTime, void setTimes(double serverSystemTime, double serverUserTime,
double clientSystemTime, double clientUserTime); double clientSystemTime, double clientUserTime);
//sends the data to the performancew database server // sends the data to the performance database server
int sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag); bool sendData(std::string access_token, std::string test_name,
std::string sys_info, std::string tag);
private: private:
std::unique_ptr<PerfDbTransfer::Stub> stub_; std::unique_ptr<PerfDbTransfer::Stub> stub_;
ClientConfig clientConfig_; ClientConfig clientConfig_;
ServerConfig serverConfig_; ServerConfig serverConfig_;
@ -107,7 +111,5 @@ private:
double clientUserTime_; double clientUserTime_;
}; };
} //namespace testing } // namespace testing
} //namespace grpc } // namespace grpc

@ -67,7 +67,6 @@ void CompositeReporter::ReportTimes(const ScenarioResult& result) {
} }
} }
void GprLogReporter::ReportQPS(const ScenarioResult& result) { void GprLogReporter::ReportQPS(const ScenarioResult& result) {
gpr_log(GPR_INFO, "QPS: %.1f", gpr_log(GPR_INFO, "QPS: %.1f",
result.latencies.Count() / result.latencies.Count() /
@ -76,10 +75,9 @@ void GprLogReporter::ReportQPS(const ScenarioResult& result) {
} }
void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) { void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) {
auto qps = auto qps = result.latencies.Count() /
result.latencies.Count() / average(result.client_resources,
average(result.client_resources, [](ResourceUsage u) { return u.wall_time; });
[](ResourceUsage u) { return u.wall_time; });
gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps, gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps,
qps / result.server_config.threads()); qps / result.server_config.threads());
@ -120,8 +118,8 @@ void GprLogReporter::ReportTimes(const ScenarioResult& result) {
void PerfDbReporter::ReportQPS(const ScenarioResult& result) { void PerfDbReporter::ReportQPS(const ScenarioResult& result) {
auto qps = result.latencies.Count() / auto qps = result.latencies.Count() /
average(result.client_resources, average(result.client_resources,
[](ResourceUsage u) { return u.wall_time; }); [](ResourceUsage u) { return u.wall_time; });
perfDbClient_.setQPS(qps); perfDbClient_.setQPS(qps);
perfDbClient_.setConfigs(result.client_config, result.server_config); perfDbClient_.setConfigs(result.client_config, result.server_config);
@ -129,8 +127,8 @@ void PerfDbReporter::ReportQPS(const ScenarioResult& result) {
void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) { void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) {
auto qps = result.latencies.Count() / auto qps = result.latencies.Count() /
average(result.client_resources, average(result.client_resources,
[](ResourceUsage u) { return u.wall_time; }); [](ResourceUsage u) { return u.wall_time; });
auto qpsPerCore = qps / result.server_config.threads(); auto qpsPerCore = qps / result.server_config.threads();
@ -141,48 +139,46 @@ void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) {
void PerfDbReporter::ReportLatency(const ScenarioResult& result) { void PerfDbReporter::ReportLatency(const ScenarioResult& result) {
perfDbClient_.setLatencies(result.latencies.Percentile(50) / 1000, perfDbClient_.setLatencies(result.latencies.Percentile(50) / 1000,
result.latencies.Percentile(90) / 1000, result.latencies.Percentile(90) / 1000,
result.latencies.Percentile(95) / 1000, result.latencies.Percentile(95) / 1000,
result.latencies.Percentile(99) / 1000, result.latencies.Percentile(99) / 1000,
result.latencies.Percentile(99.9) / 1000); result.latencies.Percentile(99.9) / 1000);
perfDbClient_.setConfigs(result.client_config, result.server_config); perfDbClient_.setConfigs(result.client_config, result.server_config);
} }
void PerfDbReporter::ReportTimes(const ScenarioResult& result) { void PerfDbReporter::ReportTimes(const ScenarioResult& result) {
double serverSystemTime = 100.0 * sum(result.server_resources, double serverSystemTime =
100.0 * sum(result.server_resources,
[](ResourceUsage u) { return u.system_time; }) / [](ResourceUsage u) { return u.system_time; }) /
sum(result.server_resources, sum(result.server_resources, [](ResourceUsage u) { return u.wall_time; });
[](ResourceUsage u) { return u.wall_time; }); double serverUserTime =
double serverUserTime = 100.0 * sum(result.server_resources, 100.0 * sum(result.server_resources,
[](ResourceUsage u) { return u.user_time; }) / [](ResourceUsage u) { return u.user_time; }) /
sum(result.server_resources, sum(result.server_resources, [](ResourceUsage u) { return u.wall_time; });
[](ResourceUsage u) { return u.wall_time; }); double clientSystemTime =
double clientSystemTime = 100.0 * sum(result.client_resources, 100.0 * sum(result.client_resources,
[](ResourceUsage u) { return u.system_time; }) / [](ResourceUsage u) { return u.system_time; }) /
sum(result.client_resources, sum(result.client_resources, [](ResourceUsage u) { return u.wall_time; });
[](ResourceUsage u) { return u.wall_time; }); double clientUserTime =
double clientUserTime = 100.0 * sum(result.client_resources, 100.0 * sum(result.client_resources,
[](ResourceUsage u) { return u.user_time; }) / [](ResourceUsage u) { return u.user_time; }) /
sum(result.client_resources, sum(result.client_resources, [](ResourceUsage u) { return u.wall_time; });
[](ResourceUsage u) { return u.wall_time; });
perfDbClient_.setTimes(serverSystemTime, serverUserTime, perfDbClient_.setTimes(serverSystemTime, serverUserTime, clientSystemTime,
clientSystemTime, clientUserTime); clientUserTime);
perfDbClient_.setConfigs(result.client_config, result.server_config); perfDbClient_.setConfigs(result.client_config, result.server_config);
} }
void PerfDbReporter::SendData() { void PerfDbReporter::SendData() {
//send data to performance database // send data to performance database
int dataState = perfDbClient_.sendData(access_token_, test_name_, sys_info_, tag_); bool dataState =
perfDbClient_.sendData(access_token_, test_name_, sys_info_, tag_);
//check state of data sending
switch(dataState) { // check state of data sending
case 1: if (dataState) {
gpr_log(GPR_INFO, "Data sent to performance database successfully"); gpr_log(GPR_INFO, "Data sent to performance database successfully");
break; } else {
case -1: gpr_log(GPR_INFO, "Data could not be sent to performance database");
gpr_log(GPR_INFO, "Data could not be sent to performance database");
break;
} }
} }

@ -107,12 +107,18 @@ class GprLogReporter : public Reporter {
/** Reporter for performance database tool */ /** Reporter for performance database tool */
class PerfDbReporter : public Reporter { class PerfDbReporter : public Reporter {
public: public:
PerfDbReporter(const string& name, const string& access_token, const string& test_name, PerfDbReporter(const string& name, const string& access_token,
const string& sys_info, const string& server_address, const string& tag) const string& test_name, const string& sys_info,
: Reporter(name), access_token_(access_token), test_name_(test_name), sys_info_(sys_info), tag_(tag) { const string& server_address, const string& tag)
perfDbClient_.init(grpc::CreateChannel(server_address, grpc::InsecureCredentials(), ChannelArguments())); : Reporter(name),
access_token_(access_token),
test_name_(test_name),
sys_info_(sys_info),
tag_(tag) {
perfDbClient_.init(grpc::CreateChannel(
server_address, grpc::InsecureCredentials(), ChannelArguments()));
} }
~PerfDbReporter() { SendData(); }; ~PerfDbReporter() GRPC_OVERRIDE { SendData(); };
private: private:
PerfDbClient perfDbClient_; PerfDbClient perfDbClient_;

Loading…
Cancel
Save