summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-12-01 16:00:42 -0800
committerdormando <dormando@rydia.net>2022-12-01 16:00:42 -0800
commit5468b726004aa9651ad77ec3db2dbb9859137b53 (patch)
tree6abccfa43dea5e5cde8ffffbe79d52151794bd7e
parent20cf8989cad866c9ffa0afbf8b06f843e33cc850 (diff)
downloadmemcached-5468b726004aa9651ad77ec3db2dbb9859137b53.tar.gz
proxy: add proxy_await_active stat
proxy_req_active shows the number of active proxy requests, but if those proxy requests make sub-requests via mcp.await() they are not accounted for. This gives the number of await's active, but not the total number of in-flight async requests.
-rw-r--r--doc/protocol.txt1
-rw-r--r--memcached.c1
-rw-r--r--memcached.h3
-rw-r--r--proxy_await.c2
4 files changed, 6 insertions, 1 deletions
diff --git a/doc/protocol.txt b/doc/protocol.txt
index 2f17415..9714bd9 100644
--- a/doc/protocol.txt
+++ b/doc/protocol.txt
@@ -1266,6 +1266,7 @@ integers separated by a colon (treat this as a floating point number).
| proxy_conn_oom | 64u | Number of out of memory errors while |
| | | serving proxy requests |
| proxy_req_active | 64u | Number of in-flight proxy requests |
+| proxy_req_await | 64u | Number of in-flight proxy async requests |
| cmd_get | 64u | Cumulative number of retrieval reqs |
| cmd_set | 64u | Cumulative number of storage reqs |
| cmd_flush | 64u | Cumulative number of flush reqs |
diff --git a/memcached.c b/memcached.c
index b7cc5d9..e949b09 100644
--- a/memcached.c
+++ b/memcached.c
@@ -1809,6 +1809,7 @@ void server_stats(ADD_STAT add_stats, conn *c) {
APPEND_STAT("proxy_conn_errors", "%llu", (unsigned long long)thread_stats.proxy_conn_errors);
APPEND_STAT("proxy_conn_oom", "%llu", (unsigned long long)thread_stats.proxy_conn_oom);
APPEND_STAT("proxy_req_active", "%llu", (unsigned long long)thread_stats.proxy_req_active);
+ APPEND_STAT("proxy_await_active", "%llu", (unsigned long long)thread_stats.proxy_await_active);
}
#endif
APPEND_STAT("cmd_get", "%llu", (unsigned long long)thread_stats.get_cmds);
diff --git a/memcached.h b/memcached.h
index af47463..860fae4 100644
--- a/memcached.h
+++ b/memcached.h
@@ -347,7 +347,8 @@ struct slab_stats {
X(proxy_conn_requests) \
X(proxy_conn_errors) \
X(proxy_conn_oom) \
- X(proxy_req_active)
+ X(proxy_req_active) \
+ X(proxy_await_active)
#endif
/**
diff --git a/proxy_await.c b/proxy_await.c
index 8eb5aa6..1486068 100644
--- a/proxy_await.c
+++ b/proxy_await.c
@@ -182,6 +182,7 @@ static void mcp_queue_await_io(conn *c, lua_State *Lc, mcp_request_t *rq, int aw
// places. Else these errors currently crash the daemon.
int mcplib_await_run(conn *c, mc_resp *resp, lua_State *L, int coro_ref) {
P_DEBUG("%s: start\n", __func__);
+ WSTAT_INCR(c, proxy_await_active, 1);
mcp_await_t *aw = lua_touserdata(L, -1);
int await_ref = luaL_ref(L, LUA_REGISTRYINDEX); // await is popped.
assert(aw != NULL);
@@ -365,6 +366,7 @@ int mcplib_await_return(io_pending_proxy_t *p) {
luaL_unref(L, LUA_REGISTRYINDEX, aw->argtable_ref);
luaL_unref(L, LUA_REGISTRYINDEX, aw->req_ref);
luaL_unref(L, LUA_REGISTRYINDEX, p->await_ref);
+ WSTAT_DECR(p->c, proxy_await_active, 1);
}
// Just remove anything we could have left on the primary VM stack