Skip to content

Conversation

@Maaarcocr
Copy link
Contributor

@Maaarcocr Maaarcocr commented May 6, 2025

This pr adds a new unwinder based on framehop, as it was suggested in #152 and some of the code here is inspired by https://github.com/sticnarf/runwind

While doing so, I made it such that any unwinder also supports resolving symbols from perfmaps a commonly used format by JIT compilers.

I've also made it possible to configure the maximum length of each stacktrace, as for my own usecases (profiling ruby applications from a native POV) 128 was too small.

In order to make framehop works I had to:

  • get a list of all dynamically linked objects
  • get the state of some registers

this changes have been tested on macos on ARM and linux on x86.

@ti-chi-bot
Copy link

ti-chi-bot bot commented May 6, 2025

Welcome @Maaarcocr! It looks like this is your first PR to tikv/pprof-rs 🎉

@YangKeao YangKeao self-requested a review May 7, 2025 03:07
@Maaarcocr Maaarcocr force-pushed the master branch 2 times, most recently from 92c9b0d to 0557997 Compare May 7, 2025 10:19
@Maaarcocr
Copy link
Contributor Author

Maaarcocr commented May 7, 2025

I've pushed a new commit that separates the perfmap implementation from the framehop unwinder, as they are different concerns. I hope this is better, we can now have perfmaps resolution even with the other unwinder if we want to.

This also reduces the changes that were needed to make this work.

@Maaarcocr Maaarcocr force-pushed the master branch 2 times, most recently from 1cc6810 to e3e2cc9 Compare May 8, 2025 15:56
perfmaps are reloaded on demand in a bg thread

Signed-off-by: Marco Concetto Rudilosso <marco.rudilosso@shopify.com>
Signed-off-by: Marco Concetto Rudilosso <marco.rudilosso@shopify.com>
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good! I'll find several devices to test it and approve before the next week.

prost-codec = ["prost", "prost-derive", "prost-build", "sha2", "_protobuf"]
protobuf-codec = ["protobuf", "protobuf-codegen", "_protobuf"]
framehop-unwinder = ["framehop", "memmap2", "object"]
perfmaps = ["arc-swap"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, could you tell me which JIT compiler you are using pprof-rs on? I'd like to have a try and test ❤️ .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH! I see, you are "profiling ruby applications from a native POV". Cool 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is for YJIT specifically and yes it's ruby!

/// Define the MAX supported stack depth. TODO: make this variable mutable.
#[cfg(feature = "large-depth")]
pub const MAX_DEPTH: usize = 1024;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! It's a good workaround to make compile-time constant configurable in the current rust construction method (though I sincerely hope it'll have better ways in the future) 👍.

Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I've merged the latest upstream. It'll be merged once CI pass 🍻 . (It seems that github is experiencing outage now 😮‍💨 )

@YangKeao YangKeao merged commit 60606fe into tikv:master May 26, 2025
59 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants