deepflow
deepflow copied to clipboard
[FR] Support for lua / nginx-lua profiling
Search before asking
- [x] I had searched in the issues and found no similar feature requirement.
Description
No response
Use case
No response
Related issues
No response
Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
-
获得 lua 虚拟机结构体字段偏移量。不同版本可能有区别。
参考代码:
-
在进程中寻找 lua 函数调用栈内存地址
参考代码:
-
将 1 和 2 通过 bpf table 传给 ebpf 程序
参考代码:
- https://github.com/deepflowio/deepflow/blob/a166226a6aa58669b88868c86ab2eca3571df7af/agent/src/ebpf/user/unwind_tracer.c#L297
相关函数:
- unwind_process_exec:进程启动时添加 lua 所需记录
- unwind_process_exit:进程退出时清理记录
-
ebpf 程序中进行栈回溯,获取 lua 栈(可能还有符号信息)并发送给用户程序
参考代码:
- 入口:https://github.com/deepflowio/deepflow/blob/a166226a6aa58669b88868c86ab2eca3571df7af/agent/src/ebpf/kernel/perf_profiler.bpf.c#L550
- Python 回溯:deepflow/agent/src/ebpf/kernel/perf_profiler.bpf.c at a166226a6aa58669b88868c86ab2eca3571df7af · dee
-
将栈中地址翻译成符号
参考代码(intpstack 相关):
- https://github.com/deepflowio/deepflow/blob/57fd682018e120dbeb13927503fe0381496b84c6/agent/src/ebpf/user/profile/stringifier.c#L665
- @woodgear
@rvql
相关代码的位置可以参考这个提交 https://github.com/deepflowio/deepflow/commit/b7dec55ec627140edc62fc15aba5dbb1b558360c