This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 48068c7 [kserver] output info on server-wide size limit
48068c7 is described below
commit 48068c7cbf4066e3d2081960b50d466baf01543d
Author: Alexey Serbin <[email protected]>
AuthorDate: Mon May 17 17:11:25 2021 -0700
[kserver] output info on server-wide size limit
With this patch, Kudu servers output an INFO log line about the maximum
number of threads in a server-wide thread pool. That's useful when
assessing how many threads a Kudu server might legitimately spawn.
Yes, those numbers can be calculated given the setting for RLIMIT_NPROC
and values in /proc/sys/kernel/pid_max and /proc/sys/kernel/threads-max,
but (a) those settings might change after the start of a server and
(b) it's convenient to have a pre-computed number ready in the logs.
Change-Id: I62b4168fc153e693f0fcc3d6d1ecfc6be0e69b47
Reviewed-on: http://gerrit.cloudera.org:8080/17474
Reviewed-by: Bankim Bhavsar <[email protected]>
Tested-by: Alexey Serbin <[email protected]>
---
src/kudu/kserver/kserver.cc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/kudu/kserver/kserver.cc b/src/kudu/kserver/kserver.cc
index d325301..73021ae 100644
--- a/src/kudu/kserver/kserver.cc
+++ b/src/kudu/kserver/kserver.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <initializer_list>
+#include <limits>
#include <memory>
#include <mutex>
#include <ostream>
@@ -28,7 +29,6 @@
#include <glog/logging.h>
#include "kudu/fs/fs_manager.h"
-#include "kudu/gutil/integral_types.h"
#include "kudu/gutil/strings/numbers.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/rpc/messenger.h"
@@ -94,7 +94,7 @@ namespace kserver {
namespace {
-int GetThreadPoolThreadLimit(Env* env) {
+int32_t GetThreadPoolThreadLimit(Env* env) {
// Maximize this process' running thread limit first, if possible.
static std::once_flag once;
std::call_once(once, [&]() {
@@ -117,7 +117,7 @@ int GetThreadPoolThreadLimit(Env* env) {
// Callers of this function expect a signed 32-bit integer, so we need to
// further cap the limit just in case it's too large.
- rlimit = std::min(rlimit, static_cast<uint64_t>(kint32max));
+ rlimit = std::min<uint64_t>(rlimit, std::numeric_limits<int32_t>::max());
// Take only 10% of the calculated limit; we don't want to hog the system.
return static_cast<int32_t>(rlimit) / 10;
@@ -159,7 +159,9 @@ Status KuduServer::Init() {
// These pools are shared by all replicas hosted by this server, and thus
// are capped at a portion of the overall per-euid thread resource limit.
- int server_wide_pool_limit = GetThreadPoolThreadLimit(fs_manager_->env());
+ auto server_wide_pool_limit = GetThreadPoolThreadLimit(fs_manager_->env());
+ LOG(INFO) << Substitute("Server-wide thread pool size limit: $0",
+ server_wide_pool_limit);
RETURN_NOT_OK(ThreadPoolBuilder("prepare")
.set_max_threads(server_wide_pool_limit)
.Build(&tablet_prepare_pool_));