-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lua Support #1889
Comments
hey @kakkoyun what's the
thanks |
This is actually quite close to the top of our priority list. However, the team needs a couple of months to get to it.
This could be quite complex. You can check #1933 and #1984 PRs for the scope of it. But it shouldn't intimidate you. If you want to give it a shot, go for it! |
I actually think it's a little more tricky than ruby/python as primarily we want to support LuaJIT, so we need something that's a mix of the native unwinder and the python/ruby unwinder, that we can switch to. @javierhonduco is already looking at how we could make switching work, but I think it's harder than it looks at first glance. On a positive note though, there is some prior art that suggests that something similar to the python/ruby purely for reading the frames should indeed work: https://github.com/yunwei37/nginx-lua-ebpf-toolkit |
Let's wait for @javierhonduco's investigation result. Thus, I'm assigning it to him for now. |
@kakkoyun Has there been any progress on this ticket? |
Awesome thanks Kemal! |
Notes on how to approach this issueLua has a couple existing profile solutions:The ideal goal is to have a Lua/Native mixed frames profiler. The apisix profiler claims to do this but its not clear how since it relies on The LuaJIT profiler avoids this problem by stashing the Lua global pointer. Questions:Can we get the lua state w/o a uprobe?W/o the ability to walk the stack this is dubious, if we could walk stack frames and identify the C/JIT call boundary its probably relatively straight forward to pluck the Lua state pointer as the first arg. Since our unwind tables tell us which is a C frame and which is a JIT frame this seems doable. The Lua global isn't stored anywhere like a thread local so we can't do what works for Python et al. Its possible that we could do something container specific, ie peak into openresty's module code and try to find the Lua context pointers but then we'd have to manage that for everything that uses luajit. Are uprobes a problem?This needs to be analyzed but my guess is the uprobe overhead is much smaller than the average Lua program execution time in most contexts. Can Lua Dwarf tables save us?It was suggested on the Lua mailing list that we can walk Lua frames using the dwarf information Lua emits to handle stack unwinding machinery needed for C++ exceptions. This doesn't work however. Lua stack unwinding only works when the Lua frame is at a boundary/exit point (ie another function call), they don't work for unwinding at any arbitrary instruction. This was the best description of this issue I could find: So our choices seem to be:
I think the best course of action is start with #1 and in parallel request/advocate/contribute #2. I don't know what the state of LuaJIT development is but this issue is encouraging: LuaJIT/LuaJIT#1092. Especially the bit about debugging. |
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889
generate them in the unwinder with more context. Also don't throw away frames when we can't get the process info. If frame pointer unwinding fails still tail call interpter unwinder luajit stack unwinding support Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889 cleanup fix lua runtime detection [pre-commit.ci lite] apply automatic fixes switch from L to G tracking which should be more reliable look below rsp make format fix rebase issues lua 5.10 kernel fixes make lua unwinder work in more cases cleanup wip get cur_L and jit_base from assembly more fixes fix instruction limits errors
generate them in the unwinder with more context. Also don't throw away frames when we can't get the process info. If frame pointer unwinding fails still tail call interpter unwinder luajit stack unwinding support Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889 cleanup fix lua runtime detection [pre-commit.ci lite] apply automatic fixes switch from L to G tracking which should be more reliable look below rsp make format fix rebase issues lua 5.10 kernel fixes make lua unwinder work in more cases cleanup wip get cur_L and jit_base from assembly more fixes fix instruction limits errors
generate them in the unwinder with more context. Also don't throw away frames when we can't get the process info. If frame pointer unwinding fails still tail call interpter unwinder luajit stack unwinding support Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889 cleanup fix lua runtime detection [pre-commit.ci lite] apply automatic fixes switch from L to G tracking which should be more reliable look below rsp make format fix rebase issues lua 5.10 kernel fixes make lua unwinder work in more cases cleanup wip get cur_L and jit_base from assembly more fixes fix instruction limits errors
generate them in the unwinder with more context. Also don't throw away frames when we can't get the process info. If frame pointer unwinding fails still tail call interpter unwinder luajit stack unwinding support Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889 cleanup fix lua runtime detection [pre-commit.ci lite] apply automatic fixes switch from L to G tracking which should be more reliable look below rsp make format fix rebase issues lua 5.10 kernel fixes make lua unwinder work in more cases cleanup wip get cur_L and jit_base from assembly more fixes fix instruction limits errors cleanup
generate them in the unwinder with more context. Also don't throw away frames when we can't get the process info. If frame pointer unwinding fails still tail call interpter unwinder luajit stack unwinding support Works with openresty and luajit with caveats. lua_State is looked up via uprobes on lua_pcall and lua_resume. If uprobes aren't enabled an attempt will be made to look up lua_State via nginx_lua_co_ctx object which seems to work well for openresty but isn't well tested. Fixes: parca-dev#1889 cleanup fix lua runtime detection [pre-commit.ci lite] apply automatic fixes switch from L to G tracking which should be more reliable look below rsp make format fix rebase issues lua 5.10 kernel fixes make lua unwinder work in more cases cleanup wip get cur_L and jit_base from assembly more fixes fix instruction limits errors cleanup
The text was updated successfully, but these errors were encountered: