* * * * * Profile results are as expected as the Spanish Inquisition I'm not upset at rewriting the code that handles the network buffering [1] as it needed work, but I'm still seeing a disporportionate amount of CPU (Central Processing Unit) time accumluate on the supposedly simpler protocol gopher. The most popular requests of both my gopher server [2] and Gemini server [3] are entries from my blog, so I take a look at the code that handles such requests for both servers. Yes, the gohper server has a bit more code dealing with links than the Gemini server (because gopher URL (Uniform Resource Location)s are almost, but not entirely, like http URLs—and the small differences are annoying), but I'm not seeing anything that stands out. Yes, the code is not quite twice as much, but the CPU utilization is more than three times as much (as of writing this). I have no other choice at this point and I constantly relearn this lession over and over again: if I'm looking into a performance issue [4], **profile the code under question!** Profile [5] profile [6] profile [7]! The code is in Lua [8] and as it happens, I've profiled Lua code before [9]. First, I want to answer this question: how much code does it take to serve a request? And I figure measuring the lines of code run is a good answer to that. I can get a baseline from that. And the code to answer that is a very easy four line change to each server: -----[ Lua ]----- local function main(iostream) local count = 0 debug.sethook(function() count = count + 1 end,'line') -- The rest of the main code debug.sethook() syslog('notice',"count=%d",count) end -----[ END OF LINE ]----- I fire up the servers locally, make a decently sized request [10] to each, and I get my results: Table: Lines of code to serve a request gopher 457035 gemini 22661 WHAT THE LITERAL XXXX‽ [Well, there's your problem! —Editor] [Just … gaaaaaaah! —Sean] I'm constantly surprised at the results of profiling—it's almost never what I think the problem is. And here, it's clear that I messed up pretty bad somewhere in the gopher code. Now off to more profiling to see where it all goes pear shaped. [1] https://github.com/spc476/lua-conmanorg/blob/4ebd6da4f82617bf87a9f6c5a0d9eb5f4f96578f/lua/net/ios.lua [2] gopher://gopher.conman.org:70/1 [3] gemini://gemini.conman.org/ [4] gopher://gopher.conman.org/0Phlog:2024/05/27.1 [5] gopher://gopher.conman.org/0Phlog:2003/01/12.1 [6] gopher://gopher.conman.org/0Phlog:2004/07/11.1 [7] gopher://gopher.conman.org/0Phlog:2019/08/21.1 [8] https://www.lua.org/ [9] gopher://gopher.conman.org/0Phlog:2019/08/21.1 [10] gopher://gopher.conman.org/0Phlog:2000/08/10.2-15.5 Email author at sean@conman.org .