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 {
// Sends client info
rpc RecordSingleClientData (SingleUserRecordRequest) returns (SingleUserRecordReply) {}
rpc RetrieveSingleUserData (SingleUserRetrieveRequest) returns (SingleUserRetrieveReply) {}
rpc RetrieveAllUsersData (AllUsersRetrieveRequest) returns (AllUsersRetrieveReply) {}
rpc RecordSingleClientData(SingleUserRecordRequest)
returns (SingleUserRecordReply) {
}
}
//Metrics to be stored
// Metrics to be stored
message Metrics {
double qps = 1;
double qps_per_core = 2;
@ -57,39 +55,7 @@ message Metrics {
double client_user_time = 11;
}
//Timestamped details
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
// Request for storing a single user's data
message SingleUserRecordRequest {
string access_token = 1;
string test_name = 2;
@ -100,25 +66,6 @@ message SingleUserRecordRequest {
ServerConfig server_config = 7;
}
//Reply to request for storing single user's data
// Reply to request for storing single user's data
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 testing {
//sets the client and server config information
void PerfDbClient::setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig) {
// sets the client and server config information
void PerfDbClient::setConfigs(const ClientConfig& clientConfig,
const ServerConfig& serverConfig) {
this->clientConfig_ = clientConfig;
this->serverConfig_ = serverConfig;
}
//sets the QPS
void PerfDbClient::setQPS(double QPS) {
this->QPS_ = QPS;
}
// sets the QPS
void PerfDbClient::setQPS(double QPS) { this->QPS_ = QPS; }
//sets the QPS per core
// sets the QPS per core
void PerfDbClient::setQPSPerCore(double QPSPerCore) {
this->QPSPerCore_ = QPSPerCore;
}
//sets the 50th, 90th, 95th, 99th and 99.9th percentile latency
void PerfDbClient::setLatencies(double percentileLatency50, double percentileLatency90,
double percentileLatency95, double percentileLatency99, double percentileLatency99Point9) {
// sets the 50th, 90th, 95th, 99th and 99.9th percentile latency
void PerfDbClient::setLatencies(double percentileLatency50,
double percentileLatency90,
double percentileLatency95,
double percentileLatency99,
double percentileLatency99Point9) {
this->percentileLatency50_ = percentileLatency50;
this->percentileLatency90_ = percentileLatency90;
this->percentileLatency95_ = percentileLatency95;
@ -62,54 +64,78 @@ void PerfDbClient::setLatencies(double percentileLatency50, double percentileLat
this->percentileLatency99Point9_ = percentileLatency99Point9;
}
//sets the server and client, user and system times
void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime,
double clientSystemTime, double clientUserTime) {
// sets the server and client, user and system times
void PerfDbClient::setTimes(double serverSystemTime, double serverUserTime,
double clientSystemTime, double clientUserTime) {
this->serverSystemTime_ = serverSystemTime;
this->serverUserTime_ = serverUserTime;
this->clientSystemTime_ = clientSystemTime;
this->clientUserTime_ = clientUserTime;
}
//sends the data to the performancew database server
int PerfDbClient::sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag) {
//Data record request object
// sends the data to the performance database server
bool PerfDbClient::sendData(std::string access_token, std::string test_name,
std::string sys_info, std::string tag) {
// Data record request object
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_test_name(test_name);
singleUserRecordRequest.set_sys_info(sys_info);
singleUserRecordRequest.set_tag(tag);
//setting configs
// setting configs
*(singleUserRecordRequest.mutable_client_config()) = this->clientConfig_;
*(singleUserRecordRequest.mutable_server_config()) = this->serverConfig_;
Metrics* metrics = singleUserRecordRequest.mutable_metrics();
//setting metrcs in data record request
if(QPS_ != DBL_MIN) metrics->set_qps(this->QPS_);
if(QPSPerCore_ != DBL_MIN) metrics->set_qps_per_core(this->QPSPerCore_);
if(percentileLatency50_ != DBL_MIN) metrics->set_perc_lat_50(this->percentileLatency50_);
if(percentileLatency90_ != DBL_MIN) 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_);
// setting metrcs in data record request
if (QPS_ != DBL_MIN) {
metrics->set_qps(this->QPS_);
}
if (QPSPerCore_ != DBL_MIN) {
metrics->set_qps_per_core(this->QPSPerCore_);
}
if (percentileLatency50_ != DBL_MIN) {
metrics->set_perc_lat_50(this->percentileLatency50_);
}
if (percentileLatency90_ != DBL_MIN) {
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;
ClientContext context;
Status status = stub_->RecordSingleClientData(&context, singleUserRecordRequest, &singleUserRecordReply);
Status status = stub_->RecordSingleClientData(
&context, singleUserRecordRequest, &singleUserRecordReply);
if (status.ok()) {
return 1; //data sent to database successfully
return true; // data sent to database successfully
} else {
return -1; //error in data sending
return false; // error in data sending
}
}
} //testing
} //grpc
} // testing
} // grpc

@ -45,13 +45,12 @@
#include <grpc++/status.h>
#include "test/cpp/qps/perf_db.grpc.pb.h"
namespace grpc{
namespace grpc {
namespace testing {
//Manages data sending to performance database server
// Manages data sending to performance database server
class PerfDbClient {
public:
public:
PerfDbClient() {
QPS_ = DBL_MIN;
QPSPerCore_ = DBL_MIN;
@ -65,32 +64,37 @@ public:
clientSystemTime_ = 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() {}
//sets the client and server config information
void setConfigs(const ClientConfig& clientConfig, const ServerConfig& serverConfig);
//sets the QPS
// sets the client and server config information
void setConfigs(const ClientConfig& clientConfig,
const ServerConfig& serverConfig);
// sets the QPS
void setQPS(double QPS);
//sets the QPS per core
// sets the QPS per core
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,
double percentileLatency95, double percentileLatency99, double percentileLatency99Point9);
double percentileLatency95, double percentileLatency99,
double percentileLatency99Point9);
//sets the server and client, user and system times
void setTimes(double serverSystemTime, double serverUserTime,
double clientSystemTime, double clientUserTime);
// sets the server and client, user and system times
void setTimes(double serverSystemTime, double serverUserTime,
double clientSystemTime, double clientUserTime);
//sends the data to the performancew database server
int sendData(std::string access_token, std::string test_name, std::string sys_info, std::string tag);
// sends the data to the performance database server
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_;
ClientConfig clientConfig_;
ServerConfig serverConfig_;
@ -107,7 +111,5 @@ private:
double clientUserTime_;
};
} //namespace testing
} //namespace grpc
} // namespace testing
} // namespace grpc

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

@ -107,12 +107,18 @@ class GprLogReporter : public Reporter {
/** Reporter for performance database tool */
class PerfDbReporter : public Reporter {
public:
PerfDbReporter(const string& name, const string& access_token, const string& test_name,
const string& sys_info, const string& server_address, const string& tag)
: 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(const string& name, const string& access_token,
const string& test_name, const string& sys_info,
const string& server_address, const string& tag)
: 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:
PerfDbClient perfDbClient_;

Loading…
Cancel
Save