| 87 | } |
| 88 | |
| 89 | size_t GetCoreNumber(const std::string& job_name, size_t total_connections) { |
| 90 | if (total_connections == 0) { |
| 91 | // NOTE(rangeng.llb): allocate one core to make seastar work correctly. |
| 92 | return 1; |
| 93 | } |
| 94 | |
| 95 | Status s; |
| 96 | int64 max_core_number = WORKER_DEFAULT_CORE_NUM; |
| 97 | if (job_name == "ps") { |
| 98 | s = ReadInt64FromEnvVar("NETWORK_PS_CORE_NUMBER", PS_DEFAULT_CORE_NUM, |
| 99 | &max_core_number); |
| 100 | } else if (IsWorker(job_name)) { |
| 101 | s = ReadInt64FromEnvVar("NETWORK_WORKER_CORE_NUMBER", |
| 102 | WORKER_DEFAULT_CORE_NUM, &max_core_number); |
| 103 | } |
| 104 | if (!s.ok()) { |
| 105 | LOG(WARNING) << "Please setup NETWORK_PS_CORE_NUMBER or" |
| 106 | << " NETWORK_WORKER_CORE_NUMBER"; |
| 107 | } |
| 108 | return std::min(total_connections, (size_t)max_core_number); |
| 109 | } |
| 110 | |
| 111 | // force to avoid cleanup static variables and global variables in seastar |
| 112 | // engine which would trigger core |
no test coverage detected