From: Aurelien DARRAGON Date: Wed, 30 Apr 2025 14:41:16 +0000 (+0200) Subject: MINOR: hlua_fcn: enforce yield after *_get_stats() methods X-Git-Tag: v3.2-dev13~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f418ac7d26de77aafd1bd13709d6257038c24e1;p=thirdparty%2Fhaproxy.git MINOR: hlua_fcn: enforce yield after *_get_stats() methods {listener,proxy,server}_get_stats() methods are know to be expensive, expecially if used under an iteration. Indeed, while automatic yield is performed every X lua instructions (defaults to 10k), computing an object's stats 10K times in a single cpu loop is not desirable and could create contention. In this patch we leverage hlua_yield_asap() at the end of *_get_stats() methods in order to force the automatic yield to occur ASAP after the method returns. Hopefully this should help in similar scenarios as the one described in GH #2903 --- diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 0ad0b7ed0..a340d0d88 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -1154,6 +1154,7 @@ int hlua_listener_get_stats(lua_State *L) hlua_fcn_pushfield(L, &stats[i]); lua_settable(L, -3); } + hlua_yield_asap(L); return 1; } @@ -1200,6 +1201,7 @@ int hlua_server_get_stats(lua_State *L) hlua_fcn_pushfield(L, &stats[i]); lua_settable(L, -3); } + hlua_yield_asap(L); return 1; } @@ -2053,6 +2055,7 @@ int hlua_proxy_get_stats(lua_State *L) hlua_fcn_pushfield(L, &stats[i]); lua_settable(L, -3); } + hlua_yield_asap(L); return 1; }