openresty / luajit2

OpenResty's Branch of LuaJIT 2
https://luajit.org/luajit.html
Other
1.2k stars 193 forks source link

lj_str_new and lj_tab hashkey CPU 100% #158

Open fairyqb opened 2 years ago

fairyqb commented 2 years ago

lj_str_new CPU 100% only in one core 8822e63e0876e34cc52f2431ad8318b

large number of strings longer than 128 in the mlcache cache. biz logic necessity

Flame Graph:

image

Perf Data: Using host libthread_db library "/lib64/libthread_db.so.1". 0x00007f9086d786f9 in lj_str_new (L=0x53f113f0, str=0x40926ae0 "{\"event\":\"mlcache:invalidations:_cache\",\"source\":\"mlcache\",\"data\":\"AUTH_OUTER_VER_KEY_X4eTEiMr-jLHD5z0VzzRPFLPOtKLwgLKQXq-TAFyOjl8vv5u2Cn2uQPthlHjlqhr11y4ZioD6L\",\"pid\":12861}e\\":\\"bearer\\",\\"exp"..., lenx=180) at lj_str.c:198 198 lj_str.c:

企业微信截图_16530919403452 https://github.com/openresty/luajit2/blob/v2.1-agentzh/src/lj_str.c

image

Related issue: https://github.com/openresty/luajit2/issues/60

agentzh commented 2 years ago

Your C backtrace is incomplete. Needs OpenResty XRay to get the full backtraces and flame graphs. OpenResty XRay can also get Lua-land flame graphs, which will be more helpful for profiling and analyzing this issue. Probably just bad Lua code on your side.

Your information above is not really helpful, unfortunately.

fairyqb commented 2 years ago

Your C backtrace is incomplete. Needs OpenResty XRay to get the full backtraces and flame graphs. OpenResty XRay can also get Lua-land flame graphs, which will be more helpful for profiling and analyzing this issue. Probably just bad Lua code on your side.

Your information above is not really helpful, unfortunately.

new flame graphs:

image

image

zhuizhuhaomeng commented 2 years ago

How long will cpu 100% last? I think you need to tweak the hash size of the mlcache with table.new(narray, nrecord)

fairyqb commented 2 years ago

How long will cpu 100% last? I think you need to tweak the hash size of the mlcache with table.new(narray, nrecord)

image

lasts many days mlcache.lua set LRU_SIZE = 512000

zhuizhuhaomeng commented 2 years ago

Which version of openresty are you using? Which OS are you running on? Can you provide a reproducible test case?

fairyqb commented 2 years ago

Which version of openresty are you using? Which OS are you running on? Can you provide a reproducible test case?

openresty version : v2.1-20180420

OS : Linux MY_011 3.10.0-1062.18.1.el7.x86_64

The new luajit version has fixed this, is testing it and seems to be working fine

zhuizhuhaomeng commented 2 years ago

The new luajit version has fixed this, is testing it and seems to be working fine That's great!