felixge / fgprof

🚀 fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together.
MIT License
2.81k stars 88 forks source link

"No source information" in pprof format #21

Closed bboreham closed 1 year ago

bboreham commented 2 years ago

I added github.com/felixge/fgprof to one of the Prometheus unit tests, which gives me good charts but no source line info:

$ go tool pprof -list processWALSamples ./tsdb.test cpu2
Total: 59.55s
No source information for github.com/prometheus/prometheus/tsdb.(*walSubsetProcessor).processWALSamples

I can work on a repro if it's interesting; didn't know whether I should expect it to work.

I'm running go version go1.17.8 linux/amd64.

felixge commented 1 year ago

Hey, sorry for the very late reply!

I just took a look, and this is currently broken because I initially was just targeting brendan gregg's folded text format (which doesn't contain file/line info) and then didn't rework the code to propagate this information when I added pprof support.

So in theory it should be a relatively easy fix! I don't know if I'll get a around to it soon, but I'd be happy to merge a patch for this quickly!

bboreham commented 1 year ago

I don't know whether I'll get around to it either, but could you suggest a file or function which is a good place to start looking how to add it?

bwplotka commented 1 year ago

Let's perhaps change the title of this issue to Missing file and line information inpprofformat. (:

zingneo commented 1 year ago

I needed this to work so I hacked it in the simplest way.

It works but it is inefficient and ugly, as Felix mentions in a TODO comment the interface between the functions need to be improved.

I didn't bother to make a PR as it is clearly not the right way of solving this, but it does work (at least for my use case, have not tried this extensively). If anyone needs this short term or want to fix this properly: https://github.com/zingneo/fgprof/commit/0bffb36c8f2941ce73812e3c7440aaf2ad5580c2

felixge commented 1 year ago

Alright, I've just implemented this in https://github.com/felixge/fgprof/pull/22 . I've tested it, but it would also be great if somebody else could try it out and let me know if it works :).

@zingneo that's a nice hack! Doing it "properly" required quite some code changes. My initial abstraction was not very good 🙈 .

zingneo commented 1 year ago

Tried out the new version and the file and line number info seems to be working as it should for my use case.

Thanks!