-
Notifications
You must be signed in to change notification settings - Fork 29
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
Support handling of perf maps #491
Conversation
A lot of our helper functionality works with PathMapsEntry objects, when really all they need would be an EntryPath. With this change we switch this functionality over to just requiring the latter. Signed-off-by: Daniel Müller <deso@posteo.net>
With an upcoming change we need to support /proc/<pid>/maps entries without a path. We can already parse them, of course, but we ultimately represent each entry as a PathMapsEntry object, which unconditionally contains a path. With this patch we remove this type and adjust the existing code to just work with MapsEntry objects directly. Signed-off-by: Daniel Müller <deso@posteo.net>
With an upcoming change we will need to be able to "resolve" the symbolic process ID Pid::Slf to the actual number. This change adds a helper method, Pid::resolve(), that accomplishes this feat. Signed-off-by: Daniel Müller <deso@posteo.net>
This change introduces the PerfMap type, which can be used for working with perf map files. These files enable generic profilers and symbolization tools to gain insight into just-in-time compiled languages, as long as their runtimes generate such a file. In Python, for example, that is supported since version 3.12 and controlled, among other things, by the value of the PYTHONPERFSUPPORT environment variable. Put in place is only the core infrastructure. Additional plumbings is necessary to use it. [0] https://docs.python.org/3/howto/perf_profiling.html Signed-off-by: Daniel Müller <deso@posteo.net>
This change enables the usage of perf maps in the library when using process based symbolization. When an address is not present in /proc/<pid>/maps entry with a path, we attempt to parse a perf map file expected at /tmp/perf-<pid>.map and use it to symbolize the address. This functionality is not explicitly exposed as a separate symbolization source. As such, user as well as blazecli will transparently make use of it. $ cargo run -p blazecli -- symbolize process --pid 3477613 0x7fbf1fc2175c > 0x007fbf1fc2175c: py::_read_directory:<frozen zipimport> @ 0x7fbf1fc21759+0x3 Closes: #256 Signed-off-by: Daniel Müller <deso@posteo.net>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #491 +/- ##
==========================================
+ Coverage 93.20% 93.37% +0.17%
==========================================
Files 45 46 +1
Lines 7710 8030 +320
==========================================
+ Hits 7186 7498 +312
- Misses 524 532 +8 ☔ View full report in Codecov by Sentry. |
I wanted to add an end-to-end test...and I did...it's just that I can't get it working in CI because the Python there doesn't come built with the necessary feature, which is very sad. |
Mmap'ing zero sized files is not allowed by the kernel (cf. mmap(2)). However, we do not want to special-case every client of the Mmap type to take care of that. If a file is empty we can just fake its contents via an empty slice. This change adjusts the Mmap type to special case zero size files internally. Signed-off-by: Daniel Müller <deso@posteo.net>
Okay, so that was some environment SNAFU. Got it working now. |
This change adds an end-to-end tests for the symbolization of addresses of JITed code. Specifically, we spin up a Python instance, instruct it to create a perf map, and then make sure that we can symbolize an address from said map. We also test working against an empty perf map file. Signed-off-by: Daniel Müller <deso@posteo.net>
Can you please take a look at the changes when you get a chance, @anakryiko? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one API question, the rest is just language questions
Support handling of perf maps. Please see individual commits for descriptions.