rubrikinc / wachy

A UI for eBPF-based performance debugging
https://rubrikinc.github.io/wachy/
Other
551 stars 17 forks source link

Question: Will this work with languages that don't use the system stack pointer register? #1

Closed jberryman closed 2 years ago

jberryman commented 2 years ago

This looks really cool! Sorry for the dumb question but I was wondering if this would work with compiled languages that don't make use of the native stack pointer register? In particular I'm looking at GHC haskell which afaiu compiles most everything into tail calls jmps, and doesn't actually use the native stack pointer register for haskell code. It does support dwarf debug symbols however.

Thanks for open-sourcing this!

viveksjain commented 2 years ago

Very interesting question, I'm learning some new stuff! The best way to find out is to try 😃 but I don't have a haskell setup at the moment. Based on what I can find/understand, if GHC isn't using call instructions then uretprobes aren't gonna work, which means wachy isn't gonna work. However, you could still use raw uprobes (e.g. with bpftrace) to understand how frequently a function is called and print its arguments.

You could potentially figure out a way to automatically instrument the jmps to "simulate" uretprobes, but I don't know how reliable that would be (and does tracing latency that way even make sense with haskell's lazy evaluation?). Alas, I don't use haskell so don't see this making its way into wachy any time soon. But if anyone is interested in implementing/exploring it please reach out!

docteurklein commented 2 years ago

I wondered the same about dynamic languages that expose USDT probes like php: https://www.php.net/manual/en/features.dtrace.dtrace.php#features.dtrace.static-probes Tools like bcc use it to do stuff: https://github.com/iovisor/bcc/blob/master/tools/lib/ucalls.py#L79

Do you think it could be applicable in wachy's context?

viveksjain commented 2 years ago

That's cool. I think you could get something like wachy to work, the issues I see are

  1. It won't allow tracing arbitrary offsets within a function so things like x won't work
  2. Every single function entry/exit triggers a probe handler, which means it will be fairly high overhead

That said, I could still see it being useful in some scenarios. However, like with haskell, I am not doing much perf work with those languages and it would be a nontrivial set of changes to get it working in wachy. So if anyone is interested in implementing it I'm more than happy to help them out, but don't see it happening any time soon!