Address reviewer comments regarding const and shortage of comments

pull/4995/head
Vijay Pai 9 years ago
parent 0d7a070e7e
commit 33e51184fc
  1. 10
      test/cpp/qps/driver.cc
  2. 4
      test/cpp/qps/limit_cores.cc
  3. 9
      test/cpp/qps/limit_cores.h

@ -65,7 +65,7 @@ static std::string get_host(const std::string& worker) {
char* port;
gpr_split_host_port(worker.c_str(), &host, &port);
string s(host);
const string s(host);
gpr_free(host);
gpr_free(port);
@ -76,7 +76,7 @@ static std::unordered_map<string, std::deque<int>> get_hosts_and_cores(
const deque<string>& workers) {
std::unordered_map<string, std::deque<int>> hosts;
for (auto it = workers.begin(); it != workers.end(); it++) {
string host = get_host(*it);
const string host = get_host(*it);
if (hosts.find(host) == hosts.end()) {
auto stub = WorkerService::NewStub(
CreateChannel(*it, InsecureChannelCredentials()));
@ -149,7 +149,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
// To be added to the result, containing the final configuration used for
// client and config (including host, etc.)
ClientConfig result_client_config;
ServerConfig result_server_config = initial_server_config;
const ServerConfig result_server_config = initial_server_config;
// Get client, server lists
auto workers = get_workers("QPS_WORKERS");
@ -224,7 +224,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
if (server_core_limit == 0 && client_core_limit > 0) {
// In this case, limit the server cores if it matches the
// same host as one or more clients
const auto& dq = hosts_cores[host_str];
const auto& dq = hosts_cores.at(host_str);
bool match = false;
int limit = dq.size();
for (size_t cli = 0; cli < num_clients; cli++) {
@ -239,7 +239,7 @@ std::unique_ptr<ScenarioResult> RunScenario(
}
}
if (server_core_limit > 0) {
auto& dq = hosts_cores[host_str];
auto& dq = hosts_cores.at(host_str);
GPR_ASSERT(dq.size() >= static_cast<size_t>(server_core_limit));
for (int core = 0; core < server_core_limit; core++) {
server_config.add_core_list(dq.front());

@ -47,12 +47,12 @@ namespace testing {
#endif
#include <sched.h>
int LimitCores(const int *cores, int cores_size) {
int num_cores = gpr_cpu_num_cores();
const int num_cores = gpr_cpu_num_cores();
int cores_set = 0;
cpu_set_t *cpup = CPU_ALLOC(num_cores);
GPR_ASSERT(cpup);
size_t size = CPU_ALLOC_SIZE(num_cores);
const size_t size = CPU_ALLOC_SIZE(num_cores);
CPU_ZERO_S(size, cpup);
if (cores_size > 0) {

@ -38,9 +38,12 @@
namespace grpc {
namespace testing {
// LimitCores takes array and size arguments (instead of vector) for more direct
// conversion from repeated field of protobuf. Use a cores_size of 0 to remove
// existing limits (from an empty repeated field)
/// LimitCores: allow this worker to only run on the cores specified in the
/// array \a cores, which is of length \a cores_size.
///
/// LimitCores takes array and size arguments (instead of vector) for direct
/// conversion from repeated field of protobuf. Use a cores_size of 0 to remove
/// existing limits (from an empty repeated field)
int LimitCores(const int *cores, int cores_size);
} // namespace testing
} // namespace grpc

Loading…
Cancel
Save