Samsung / walrus

WebAssembly Lightweight RUntime
Apache License 2.0
35 stars 10 forks source link

Perf JITDump #240

Closed vorosl closed 1 month ago

vorosl commented 2 months ago

Create JITDump file for analyzing Walrus with Linux Perf tool

clover2123 commented 2 months ago

How can we analyze JIT code with perf tool? Would you please add some guide/instruction in README file or seperate doc file?

zherczeg commented 2 months ago

Unfortunately debugging jit with perf is rather complex, and we needed to debug the perf tool to understand everything because the lack of documentation. The concept is, that the application creates a dump, which contains events with time stamps. The events can be creating a new jit code, moving jit code, etc. The file name of the jit dump is fixed (jit-pid.dump), and only one can be created. This file must be mapped as executable file (!), otherwise the perf tool ignores the mmap mapping. Then, the jit helper in perf can convert this file to a large number of .so files. This command is called inject. Each .so file contains a single jit function and its corresponding debug info. From the perspective of perf report, these are normal shared objects containing the executable code of the application. So perf report is not modified to handle jit code. The trade-off is creating a large number of temporary .so files.

This info should be in the documentation as well.