deepflow icon indicating copy to clipboard operation
deepflow copied to clipboard

[FR] Support for lua / nginx-lua profiling

Open sharang opened this issue 7 months ago • 4 comments

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

sharang avatar Jun 17 '25 10:06 sharang

  1. 获得 lua 虚拟机结构体字段偏移量。不同版本可能有区别。

    参考代码:

  2. 在进程中寻找 lua 函数调用栈内存地址

    参考代码:

  3. 将 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:进程退出时清理记录
  4. ebpf 程序中进行栈回溯,获取 lua 栈(可能还有符号信息)并发送给用户程序

    参考代码:

  5. 将栈中地址翻译成符号

    参考代码(intpstack 相关):

    • https://github.com/deepflowio/deepflow/blob/57fd682018e120dbeb13927503fe0381496b84c6/agent/src/ebpf/user/profile/stringifier.c#L665

sharang avatar Jun 17 '25 10:06 sharang

  • @woodgear

sharang avatar Jun 17 '25 10:06 sharang

@rvql

sharang avatar Jun 17 '25 10:06 sharang

相关代码的位置可以参考这个提交 https://github.com/deepflowio/deepflow/commit/b7dec55ec627140edc62fc15aba5dbb1b558360c

rvql avatar Jun 23 '25 09:06 rvql