From 4fb39b6700c2a08b7de595fbff8102b84c79e562 Mon Sep 17 00:00:00 2001 From: "Meir Shpilraien (Spielrein)" Date: Wed, 6 Oct 2021 11:33:01 +0300 Subject: [PATCH] Added module-acquire-GIL latency stats (#9608) The new value indicates how long Redis wait to acquire the GIL after sleep. This can help identify problems where a module perform some background operation for a long time (with the GIL held) and blocks the Redis main thread. --- src/server.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server.c b/src/server.c index 8ce96a876..f2549caea 100644 --- a/src/server.c +++ b/src/server.c @@ -2973,7 +2973,15 @@ void afterSleep(struct aeEventLoop *eventLoop) { /* Acquire the modules GIL so that their threads won't touch anything. */ if (!ProcessingEventsWhileBlocked) { - if (moduleCount()) moduleAcquireGIL(); + if (moduleCount()) { + mstime_t latency; + latencyStartMonitor(latency); + + moduleAcquireGIL(); + + latencyEndMonitor(latency); + latencyAddSampleIfNeeded("module-acquire-GIL",latency); + } } }