Reimplement the pprof to support Python stacks#99
Open
reiase wants to merge 8 commits into
Open
Conversation
Adds a new `probing/crates/pprof` crate that provides signal handling and timer management for CPU profiling. The crate includes: - Signal handler setup for SIGPROF - Timer management via setitimer - Public API for controlling profiling frequency and handlers
The previous implementation had redundant checks and error handling. Simplify the logic to only validate when the frequency is Nothing and directly set the frequency otherwise.
The RawCallLocation fields need to be public for use in other modules. Also added the Clone trait for copying instances. Enable iter_map_windows feature and spawn pprof task The iter_map_windows feature is needed for upcoming iterator operations. The pprof_task is now spawned on server startup for profiling.
generation - Replace pprof-rs with custom signal handler and backtrace collection - Add new flamegraph generation implementation - Improve stack merging logic for Python/native frames - Update dependencies including cpp_demangle 0.4.4 - Add smallvec for efficient frame storage - Implement async processing of profiling samples - Add thread-safe caching of profiling records
This modifies the Content-Disposition header to display flamegraphs directly in the browser rather than forcing a download.
yangrudan
reviewed
Aug 12, 2025
| use probing_proto::prelude::CallFrame; | ||
|
|
||
| pub(crate) struct Report { | ||
| offset: i64, |
Owner
Author
There was a problem hiding this comment.
计划用来选择计算火焰图使用的数据的范围,功能暂时未实现
| pub fn pprof_handler() { | ||
| PPROF_HOLDER.setup(100); | ||
| log::debug!("Starting pprof task to receive records"); | ||
| let backtrace_id: u64 = 0; |
… pprof record handling and async processing
Collaborator
yangrudan
reviewed
Nov 6, 2025
| pub const MAX_DEPTH: usize = 512; | ||
|
|
||
| #[allow(static_mut_refs)] | ||
| unsafe extern "C" fn pprof_handler() { |
Collaborator
There was a problem hiding this comment.
@reiase 侯老师, 我好像知道为什么提高采样频率会出现卡死的问题了, 参考pr105, pprof这里作为信号的handler函数, 直接调用backtrace库是不安全的. https://www.github.com/rust-lang/backtrace-rs/issues/742
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.