Make dynamic sizing of async threads work again

pull/4995/head
Vijay Pai 9 years ago
parent c64736d852
commit c5eec2be89
  1. 3
      test/cpp/qps/client.h
  2. 7
      test/cpp/qps/client_async.cc

@ -324,7 +324,7 @@ class ClientImpl : public Client {
std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)> std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)>
create_stub) create_stub)
: channels_(config.client_channels()), create_stub_(create_stub) { : channels_(config.client_channels()), create_stub_(create_stub) {
LimitCores(config.core_list().data(), config.core_list_size()); cores_ = LimitCores(config.core_list().data(), config.core_list_size());
for (int i = 0; i < config.client_channels(); i++) { for (int i = 0; i < config.client_channels(); i++) {
channels_[i].init(config.server_targets(i % config.server_targets_size()), channels_[i].init(config.server_targets(i % config.server_targets_size()),
@ -337,6 +337,7 @@ class ClientImpl : public Client {
virtual ~ClientImpl() {} virtual ~ClientImpl() {}
protected: protected:
int cores_;
RequestType request_; RequestType request_;
class ClientChannelInfo { class ClientChannelInfo {

@ -159,6 +159,7 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
using Client::SetupLoadTest; using Client::SetupLoadTest;
using Client::NextIssueTime; using Client::NextIssueTime;
using Client::closed_loop_; using Client::closed_loop_;
using ClientImpl<StubType, RequestType>::cores_;
using ClientImpl<StubType, RequestType>::channels_; using ClientImpl<StubType, RequestType>::channels_;
using ClientImpl<StubType, RequestType>::request_; using ClientImpl<StubType, RequestType>::request_;
AsyncClient(const ClientConfig& config, AsyncClient(const ClientConfig& config,
@ -345,11 +346,11 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
private: private:
bool val_; bool val_;
}; };
static int NumThreads(const ClientConfig& config) { int NumThreads(const ClientConfig& config) {
int num_threads = config.async_client_threads(); int num_threads = config.async_client_threads();
if (num_threads <= 0) { // Use dynamic sizing if (num_threads <= 0) { // Use dynamic sizing
num_threads = gpr_cpu_num_cores(); num_threads = cores_;
gpr_log(GPR_INFO, "Sizing client server to %d threads", num_threads); gpr_log(GPR_INFO, "Sizing async client to %d threads", num_threads);
} }
return num_threads; return num_threads;
} }

Loading…
Cancel
Save