You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ww...@apache.org on 2023/01/28 06:17:39 UTC
[brpc] branch master updated: show server concurrency in status service (#2097)
This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new afa14c7a show server concurrency in status service (#2097)
afa14c7a is described below
commit afa14c7a8ea8b6d2ae6165bd33018c15e15c6e38
Author: Bright Chen <ch...@bigo.sg>
AuthorDate: Sat Jan 28 14:17:29 2023 +0800
show server concurrency in status service (#2097)
---
src/brpc/builtin/status_service.cpp | 20 +++++++++++++++++++-
src/brpc/server.cpp | 9 ++++++++-
src/brpc/server.h | 5 +++++
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/brpc/builtin/status_service.cpp b/src/brpc/builtin/status_service.cpp
index 0a2ca7ca..a6f5a4da 100644
--- a/src/brpc/builtin/status_service.cpp
+++ b/src/brpc/builtin/status_service.cpp
@@ -109,7 +109,25 @@ void StatusService::default_method(::google::protobuf::RpcController* cntl_base,
os << mc;
}
os << '\n';
-
+
+ // concurrency
+ if (use_html) {
+ os << "<p class=\"variable\">";
+ }
+ os << "concurrency: ";
+ if (use_html) {
+ os << "<span id=\"value-" << server->ServerPrefix()
+ << "_concurrency\">";
+ }
+ os << server->Concurrency();
+ if (use_html) {
+ os << "</span></p><div class=\"detail\"><div id=\""
+ << server->ServerPrefix()
+ << "_concurrency\" class=\"flot-placeholder\"></div></div>";
+ }
+ os << '\n';
+
+
const Server::ServiceMap &services = server->_fullname_service_map;
std::ostringstream desc;
DescribeOptions desc_options;
diff --git a/src/brpc/server.cpp b/src/brpc/server.cpp
index 2087cbcf..a7db3193 100644
--- a/src/brpc/server.cpp
+++ b/src/brpc/server.cpp
@@ -272,6 +272,10 @@ static bvar::Vector<unsigned, 2> GetSessionLocalDataCount(void* arg) {
return v;
}
+static int cast_no_barrier_int(void* arg) {
+ return butil::subtle::NoBarrier_Load(static_cast<int*>(arg));
+}
+
std::string Server::ServerPrefix() const {
if(_options.server_info_name.empty()) {
return butil::string_printf("%s_%d", g_server_info_prefix, listen_address().port);
@@ -292,6 +296,8 @@ void* Server::UpdateDerivedVars(void* arg) {
server->_eps_bvar.expose_as(prefix, "eps");
+ server->_concurrency_bvar.expose_as(prefix, "concurrency");
+
bvar::PassiveStatus<timeval> uptime_st(
prefix, "uptime", GetUptime, (void*)(intptr_t)start_us);
@@ -401,7 +407,8 @@ Server::Server(ProfilerLinker)
, _derivative_thread(INVALID_BTHREAD)
, _keytable_pool(NULL)
, _eps_bvar(&_nerror_bvar)
- , _concurrency(0) {
+ , _concurrency(0)
+ , _concurrency_bvar(cast_no_barrier_int, &_concurrency) {
BAIDU_CASSERT(offsetof(Server, _concurrency) % 64 == 0,
Server_concurrency_must_be_aligned_by_cacheline);
}
diff --git a/src/brpc/server.h b/src/brpc/server.h
index 0974ce12..1c0d8c82 100644
--- a/src/brpc/server.h
+++ b/src/brpc/server.h
@@ -547,6 +547,10 @@ public:
int MaxConcurrencyOf(google::protobuf::Service* service,
const butil::StringPiece& method_name) const;
+ int Concurrency() const {
+ return butil::subtle::NoBarrier_Load(&_concurrency);
+ };
+
private:
friend class StatusService;
friend class ProtobufsService;
@@ -696,6 +700,7 @@ friend class Controller;
mutable bvar::Adder<int64_t> _nerror_bvar;
mutable bvar::PerSecond<bvar::Adder<int64_t> > _eps_bvar;
BAIDU_CACHELINE_ALIGNMENT mutable int32_t _concurrency;
+ bvar::PassiveStatus<int32_t> _concurrency_bvar;
};
// Get the data attached to current searching thread. The data is created by
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org