Skip to content
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

Use the verbose parameter to enable the tracer's debugging without recompiling the program #145

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tsint
Copy link
Contributor

@tsint tsint commented Sep 2, 2024

Currently, to enable BPF debugging, you need to recompile the profiler, replace the application on the server, and then replace it back after obtaining useful information. This is very inconvenient, so I thought of directly integrating the BPF program with BPF debugging enabled into the profiler. If BPF debugging needs to be enabled, you only need to restart the application and modify the parameters.

As shown below, you can easily obtain the BPF debug log output.

            etcd-1921    [003] d.h2.  4529.247295: bpf_trace_printk: delta index 6, addrLow 0x3b00, unwindInfo 174

            etcd-1921    [003] d.h2.  4529.247296: bpf_trace_printk: unwind: fp+16

            etcd-1921    [003] d.h2.  4529.247296: bpf_trace_printk: unwind: cfa+-16

            etcd-1921    [003] d.h2.  4529.247297: bpf_trace_printk:  pc: 46b2c5 sp: c00006fff8 fp: 7ffe3eb68f90

            etcd-1921    [003] d.h2.  4529.247297: bpf_trace_printk: ==== Resolve next frame unwinder: frame 5 ====

            etcd-1921    [003] d.h2.  4529.247298: bpf_trace_printk: Text section id for PC 46b2c5 is 178b55ad52677a08 (unwinder 1)

            etcd-1921    [003] d.h2.  4529.247298: bpf_trace_printk: Text section bias is 0, and offset is 46b2c5

            etcd-1921    [003] d.h2.  4529.247298: bpf_trace_printk: ==== unwind_native 5 ====

            etcd-1921    [003] d.h2.  4529.247299: bpf_trace_printk: Pushing 178b55ad52677a08 46b2c5 to position 5 on stack

            etcd-1921    [003] d.h2.  4529.247299: bpf_trace_printk: Look up stack delta for 178b55ad52677a08:46b2c5

            etcd-1921    [003] d.h2.  4529.247300: bpf_trace_printk: Intervals should be from 7 to 219 (mapID 9)

            etcd-1921    [003] d.h2.  4529.247301: bpf_trace_printk: delta index 60, addrLow 0xb2c0, unwindInfo 32769

@tsint tsint requested review from a team September 2, 2024 02:38
@tsint tsint force-pushed the pr_debugbpf branch 3 times, most recently from 16053f2 to 81eafe1 Compare September 2, 2024 03:13
main.go Outdated Show resolved Hide resolved
cli_flags.go Outdated Show resolved Hide resolved
@tsint tsint changed the title Add a debug-bpf parameter to the profiler to enable BPF debugging wit… Enable BPF debugging using the verbose parameter without recompiling the BPF program Sep 2, 2024
@athre0z
Copy link
Contributor

athre0z commented Sep 2, 2024

Hmm, I had thought about this as well, but I'm not sure whether it's a good idea: the debug blobs are 1MB each, and we'll be updating them frequently. This will probably have rather significant impact on the repository size in the long run. If we want this, we'll probably have to stop committing tracer blobs into git, which in turn means that this repository can no longer be pulled in as a Go module (without an external build system).

@tsint
Copy link
Contributor Author

tsint commented Sep 2, 2024

Hmm, I had thought about this as well, but I'm not sure whether it's a good idea: the debug blobs are 1MB each, and we'll be updating them frequently. This will probably have rather significant impact on the repository size in the long run. If we want this, we'll probably have to stop committing tracer blobs into git, which in turn means that this repository can no longer be pulled in as a Go module (without an external build system).

What if we put the debug blobs in a separate module and do not commit these debug blobs to git to reduce the impact on the repository size, while keeping the original tracker blobs unchanged? Would this address your concerns?

@athre0z
Copy link
Contributor

athre0z commented Sep 2, 2024

Hmm yeah, something along those lines could work. We don't have to go with a separate Go module, though, if that is what you are proposing. It'd probably be enough to go:embed them in a separate file with a _sometag.go suffix that is only compiled in when the person building the profiler explicitly requests it. Other than with the regular tracers, the responsibility to make sure the debug tracers are built somehow before go:embed kicks in would lie with the user. Maybe debugtracers could be a good name for such a tag.

@tsint
Copy link
Contributor Author

tsint commented Sep 3, 2024

Hmm yeah, something along those lines could work. We don't have to go with a separate Go module, though, if that is what you are proposing. It'd probably be enough to go:embed them in a separate file with a _sometag.go suffix that is only compiled in when the person building the profiler explicitly requests it. Other than with the regular tracers, the responsibility to make sure the debug tracers are built somehow before go:embed kicks in would lie with the user. Maybe debugtracers could be a good name for such a tag.

Your suggestion is a great idea.

@tsint tsint force-pushed the pr_debugbpf branch 5 times, most recently from 2d37db8 to 84fddb9 Compare September 3, 2024 01:57
@tsint tsint changed the title Enable BPF debugging using the verbose parameter without recompiling the BPF program Use the verbose parameter to enable the tracer's debugging without recompiling the program Sep 3, 2024
support/debugtracer_amd64.go Outdated Show resolved Hide resolved
support/ebpf/Makefile Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants