integrate ScenarioResult proto into qps driver

pull/6158/head
Jan Tattermusch 9 years ago
parent 05bb5b9326
commit f2ba7fe037
  1. 17
      test/cpp/qps/driver.cc
  2. 23
      test/cpp/qps/driver.h
  3. 1
      test/cpp/qps/qps_driver.cc
  4. 111
      test/cpp/qps/report.cc
  5. 23
      test/cpp/qps/report.h
  6. 8
      test/cpp/util/benchmark_config.cc

@ -343,8 +343,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
// Finish a run
std::unique_ptr<ScenarioResult> result(new ScenarioResult);
result->client_config = result_client_config;
result->server_config = result_server_config;
Histogram merged_latencies;
gpr_log(GPR_INFO, "Finishing clients");
for (auto client = &clients[0]; client != &clients[num_clients]; client++) {
GPR_ASSERT(client->stream->Write(client_mark));
@ -353,9 +353,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
for (auto client = &clients[0]; client != &clients[num_clients]; client++) {
GPR_ASSERT(client->stream->Read(&client_status));
const auto& stats = client_status.stats();
result->latencies.MergeProto(stats.latencies());
result->client_resources.emplace_back(
stats.time_elapsed(), stats.time_user(), stats.time_system(), -1);
merged_latencies.MergeProto(stats.latencies());
result->add_client_stats()->CopyFrom(stats);
GPR_ASSERT(!client->stream->Read(&client_status));
}
for (auto client = &clients[0]; client != &clients[num_clients]; client++) {
@ -363,6 +362,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
}
delete[] clients;
merged_latencies.FillProto(result->mutable_latencies());
gpr_log(GPR_INFO, "Finishing servers");
for (auto server = &servers[0]; server != &servers[num_servers]; server++) {
GPR_ASSERT(server->stream->Write(server_mark));
@ -370,10 +371,8 @@ std::unique_ptr<ScenarioResult> RunScenario(
}
for (auto server = &servers[0]; server != &servers[num_servers]; server++) {
GPR_ASSERT(server->stream->Read(&server_status));
const auto& stats = server_status.stats();
result->server_resources.emplace_back(
stats.time_elapsed(), stats.time_user(), stats.time_system(),
server_status.cores());
result->add_server_stats()->CopyFrom(server_status.stats());
result->add_server_cores(server_status.cores());
GPR_ASSERT(!server->stream->Read(&server_status));
}
for (auto server = &servers[0]; server != &servers[num_servers]; server++) {

@ -41,29 +41,6 @@
namespace grpc {
namespace testing {
class ResourceUsage {
public:
ResourceUsage(double w, double u, double s, int c)
: wall_time_(w), user_time_(u), system_time_(s), cores_(c) {}
double wall_time() const { return wall_time_; }
double user_time() const { return user_time_; }
double system_time() const { return system_time_; }
int cores() const { return cores_; }
private:
double wall_time_;
double user_time_;
double system_time_;
int cores_;
};
struct ScenarioResult {
Histogram latencies;
std::vector<ResourceUsage> client_resources;
std::vector<ResourceUsage> server_resources;
ClientConfig client_config;
ServerConfig server_config;
};
std::unique_ptr<ScenarioResult> RunScenario(
const grpc::testing::ClientConfig& client_config, size_t num_clients,

@ -85,7 +85,6 @@ using grpc::testing::ServerConfig;
using grpc::testing::ClientType;
using grpc::testing::ServerType;
using grpc::testing::RpcType;
using grpc::testing::ResourceUsage;
using grpc::testing::SecurityParams;
namespace grpc {

@ -40,10 +40,13 @@
namespace grpc {
namespace testing {
static double WallTime(ResourceUsage u) { return u.wall_time(); }
static double UserTime(ResourceUsage u) { return u.user_time(); }
static double SystemTime(ResourceUsage u) { return u.system_time(); }
static int Cores(ResourceUsage u) { return u.cores(); }
static double WallTime(ClientStats s) { return s.time_elapsed(); }
static double SystemTime(ClientStats s) { return s.time_system(); }
static double UserTime(ClientStats s) { return s.time_user(); }
static double ServerWallTime(ServerStats s) { return s.time_elapsed(); }
static double ServerSystemTime(ServerStats s) { return s.time_system(); }
static double ServerUserTime(ServerStats s) { return s.time_user(); }
static int Cores(int n) { return n; }
void CompositeReporter::add(std::unique_ptr<Reporter> reporter) {
reporters_.emplace_back(std::move(reporter));
@ -74,102 +77,62 @@ void CompositeReporter::ReportTimes(const ScenarioResult& result) {
}
void GprLogReporter::ReportQPS(const ScenarioResult& result) {
gpr_log(
GPR_INFO, "QPS: %.1f",
result.latencies.Count() / average(result.client_resources, WallTime));
Histogram histogram;
histogram.MergeProto(result.latencies());
gpr_log(GPR_INFO, "QPS: %.1f",
histogram.Count() / average(result.client_stats(), WallTime));
}
void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result) {
auto qps =
result.latencies.Count() / average(result.client_resources, WallTime);
Histogram histogram;
histogram.MergeProto(result.latencies());
auto qps = histogram.Count() / average(result.client_stats(), WallTime);
gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps,
qps / sum(result.server_resources, Cores));
qps / sum(result.server_cores(), Cores));
}
void GprLogReporter::ReportLatency(const ScenarioResult& result) {
Histogram histogram;
histogram.MergeProto(result.latencies());
gpr_log(GPR_INFO,
"Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us",
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);
histogram.Percentile(50) / 1000,
histogram.Percentile(90) / 1000,
histogram.Percentile(95) / 1000,
histogram.Percentile(99) / 1000,
histogram.Percentile(99.9) / 1000);
}
void GprLogReporter::ReportTimes(const ScenarioResult& result) {
gpr_log(GPR_INFO, "Server system time: %.2f%%",
100.0 * sum(result.server_resources, SystemTime) /
sum(result.server_resources, WallTime));
100.0 * sum(result.server_stats(), ServerSystemTime) /
sum(result.server_stats(), ServerWallTime));
gpr_log(GPR_INFO, "Server user time: %.2f%%",
100.0 * sum(result.server_resources, UserTime) /
sum(result.server_resources, WallTime));
100.0 * sum(result.server_stats(), ServerUserTime) /
sum(result.server_stats(), ServerWallTime));
gpr_log(GPR_INFO, "Client system time: %.2f%%",
100.0 * sum(result.client_resources, SystemTime) /
sum(result.client_resources, WallTime));
100.0 * sum(result.client_stats(), SystemTime) /
sum(result.client_stats(), WallTime));
gpr_log(GPR_INFO, "Client user time: %.2f%%",
100.0 * sum(result.client_resources, UserTime) /
sum(result.client_resources, WallTime));
100.0 * sum(result.client_stats(), UserTime) /
sum(result.client_stats(), WallTime));
}
void PerfDbReporter::ReportQPS(const ScenarioResult& result) {
auto qps =
result.latencies.Count() / average(result.client_resources, WallTime);
void JsonReporter::ReportQPS(const ScenarioResult& result) {
perf_db_client_.setQps(qps);
perf_db_client_.setConfigs(result.client_config, result.server_config);
}
void PerfDbReporter::ReportQPSPerCore(const ScenarioResult& result) {
auto qps =
result.latencies.Count() / average(result.client_resources, WallTime);
auto qps_per_core = qps / sum(result.server_resources, Cores);
perf_db_client_.setQps(qps);
perf_db_client_.setQpsPerCore(qps_per_core);
perf_db_client_.setConfigs(result.client_config, result.server_config);
}
void PerfDbReporter::ReportLatency(const ScenarioResult& result) {
perf_db_client_.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);
perf_db_client_.setConfigs(result.client_config, result.server_config);
void JsonReporter::ReportQPSPerCore(const ScenarioResult& result) {
// NOP - all reporting is handled by ReportQPS.
}
void PerfDbReporter::ReportTimes(const ScenarioResult& result) {
const double server_system_time = 100.0 *
sum(result.server_resources, SystemTime) /
sum(result.server_resources, WallTime);
const double server_user_time = 100.0 *
sum(result.server_resources, UserTime) /
sum(result.server_resources, WallTime);
const double client_system_time = 100.0 *
sum(result.client_resources, SystemTime) /
sum(result.client_resources, WallTime);
const double client_user_time = 100.0 *
sum(result.client_resources, UserTime) /
sum(result.client_resources, WallTime);
perf_db_client_.setTimes(server_system_time, server_user_time,
client_system_time, client_user_time);
perf_db_client_.setConfigs(result.client_config, result.server_config);
void JsonReporter::ReportLatency(const ScenarioResult& result) {
// NOP - all reporting is handled by ReportQPS.
}
void PerfDbReporter::SendData() {
// send data to performance database
bool data_state =
perf_db_client_.sendData(hashed_id_, test_name_, sys_info_, tag_);
// check state of data sending
if (data_state) {
gpr_log(GPR_INFO, "Data sent to performance database successfully");
} else {
gpr_log(GPR_INFO, "Data could not be sent to performance database");
}
void JsonReporter::ReportTimes(const ScenarioResult& result) {
// NOP - all reporting is handled by ReportQPS.
}
} // namespace testing

@ -104,33 +104,16 @@ class GprLogReporter : public Reporter {
void ReportTimes(const ScenarioResult& result) GRPC_OVERRIDE;
};
/** Reporter for performance database tool */
class PerfDbReporter : public Reporter {
/** Dumps the report to a JSON file. */
class JsonReporter : public Reporter {
public:
PerfDbReporter(const string& name, const string& hashed_id,
const string& test_name, const string& sys_info,
const string& server_address, const string& tag)
: Reporter(name),
hashed_id_(hashed_id),
test_name_(test_name),
sys_info_(sys_info),
tag_(tag) {
perf_db_client_.init(grpc::CreateChannel(
server_address, grpc::InsecureChannelCredentials()));
}
~PerfDbReporter() GRPC_OVERRIDE { SendData(); };
JsonReporter(const string& name) : Reporter(name) {}
private:
PerfDbClient perf_db_client_;
std::string hashed_id_;
std::string test_name_;
std::string sys_info_;
std::string tag_;
void ReportQPS(const ScenarioResult& result) GRPC_OVERRIDE;
void ReportQPSPerCore(const ScenarioResult& result) GRPC_OVERRIDE;
void ReportLatency(const ScenarioResult& result) GRPC_OVERRIDE;
void ReportTimes(const ScenarioResult& result) GRPC_OVERRIDE;
void SendData();
};
} // namespace testing

@ -37,9 +37,6 @@
DEFINE_bool(enable_log_reporter, true,
"Enable reporting of benchmark results through GprLog");
DEFINE_bool(report_metrics_db, false,
"True if metrics to be reported to performance database");
DEFINE_string(hashed_id, "", "Hash of the user id");
DEFINE_string(test_name, "", "Name of the test being executed");
@ -71,11 +68,6 @@ static std::shared_ptr<Reporter> InitBenchmarkReporters() {
composite_reporter->add(
std::unique_ptr<Reporter>(new GprLogReporter("LogReporter")));
}
if (FLAGS_report_metrics_db) {
composite_reporter->add(std::unique_ptr<Reporter>(
new PerfDbReporter("PerfDbReporter", FLAGS_hashed_id, FLAGS_test_name,
FLAGS_sys_info, FLAGS_server_address, FLAGS_tag)));
}
return std::shared_ptr<Reporter>(composite_reporter);
}

Loading…
Cancel
Save