kingluo commented on issue #7949:
URL: https://github.com/apache/apisix/issues/7949#issuecomment-1257198250

   @hahayyum I rewrite the profiling logic in systemtap.
   
   https://gist.github.com/kingluo/50b8589069f5f11a78d2136c1155d613
   
   Usage:
   
   ```
   git clone https://github.com/api7/stapxx
   cd stapxx
   export PATH=$PWD:$PATH
   ./samples/lua-leaks.sxx -D STP_NO_OVERLOAD -D MAXMAPENTRIES=80000 --arg 
time=30 -x 36998
   # If you encounter systemtap memory usage and cycle overhead issue,
   # you could tune the parameters to run it.
   # But keep in mind that you should avoid CPU and memory abuse,
   # which would slow down the whole system and cause OOM
   ./samples/lua-leaks.sxx -D STP_NO_OVERLOAD -D MAXMAPENTRIES=80000 --arg 
time=30 -x 36998
   ```
   
   This script would sum up alloc/free statistics and show the top 5 backtraces 
where memory not free yet:
   
   ```
   WARNING: Start tracing 36998 (/usr/local/openresty-debug/nginx/sbin/nginx)...
   WARNING: Wait for 30 sec to complete.
    T:@/opt/apisix.fork/apisix/leak.lua:7
   @/opt/apisix.fork/apisix/leak.lua:7
   @/opt/apisix.fork/apisix/leak.lua:17
   local : 0x0
    demo : 0xde
    = : 0x0
    require("apisix.leak"); : 0x0
    return : 0x0
    function() : 0xf
    demo.run(); : 0xde
    ngx.say("ok"); : 0x0
    end:1
   @/opt/apisix.fork/apisix/plugins/serverless/init.lua:75
   @/opt/apisix.fork/apisix/plugin.lua:911
   @/opt/apisix.fork/apisix/init.lua:329
   =access_by_lua(nginx.conf:347):0
    : 0xe
           total 1840832 bytes
   
   ```
   
   Also noting that use it only in your test env with caution!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to