12345678910111213141516171819202122232425262728293031323334353637383940 |
- --- contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc (index)
- +++ contrib/libs/grpc/src/cpp/common/completion_queue_cc.cc (working tree)
- @@ -31,10 +31,23 @@
- #include "src/core/lib/gpr/useful.h"
- #include "src/core/lib/gprpp/sync.h"
- #include "src/core/lib/gprpp/thd.h"
- +#include "src/core/lib/gprpp/env.h"
- +#include "src/core/lib/gpr/string.h"
-
- namespace grpc {
- namespace {
-
- +size_t GetNextingThreadNumFromEnv() {
- + auto value = grpc_core::GetEnv("GRPC_NEXTING_THREAD_NUM_ENV");
- + if (!value.has_value()) return 0;
- + int parse_succeeded = gpr_parse_nonnegative_int(value->c_str());
- +
- + if (parse_succeeded <= 0) {
- + return 0;
- + }
- + return static_cast<size_t>(parse_succeeded);
- +}
- +
- gpr_once g_once_init_callback_alternative = GPR_ONCE_INIT;
- grpc_core::Mutex* g_callback_alternative_mu;
-
- @@ -55,6 +68,13 @@ struct CallbackAlternativeCQ {
- cq = new CompletionQueue;
- int num_nexting_threads =
- grpc_core::Clamp(gpr_cpu_num_cores() / 2, 2u, 16u);
- +
- + auto threads_limit_env = GetNextingThreadNumFromEnv();
- + if (threads_limit_env) {
- + gpr_log(GPR_INFO, "Nexting thread number changed via env from %d to %zd", num_nexting_threads, threads_limit_env);
- + num_nexting_threads = static_cast<int>(threads_limit_env);
- + }
- +
- nexting_threads = new std::vector<grpc_core::Thread>;
- for (int i = 0; i < num_nexting_threads; i++) {
- nexting_threads->emplace_back(
|