From: Daurnimator <quae@xxxxxxxxxxxxxxx>
Date: Fri, 19 May 2017 17:59:59 +1000
Subject: Re: Optimisation of logging on a hot code path
On 19 May 2017 at 17:53, Thijs Schreijer <thijs@xxxxxxxxxxxxxxxxx> wrote:
I have an occasional need for extensive logging on a very hot codepath. I’m
wondering what the best approach would be to this?
I’ve seen some empty log functions, like:
local log
if loglevel > 2 then
log = ngx.log
else
log = function() end
end
But I’d expect it to still be a function call at runtime that I’d rather
avoid. (Though it would be nice if LuaJIT would optimise it away)
Any best practices to share?
I would have expected the jit to inline the function call; and hence
be optimized away.
Have you checked to see if this is happening?