feat: add pprof api#1627
feat: add pprof api#1627jiacai2050 merged 4 commits intoapache:analytic-enginefrom BaldDemian:analytic-engine
Conversation
|
how to test
|
|
I doubt the necessity of adding these two scripts in integration tests🤔. A simple |
There was a problem hiding this comment.
Pull Request Overview
Adds a new pprof-based heap profiling endpoint to the HTTP server, implements the backend dump logic using jemalloc’s pprof interface, and provides integration scripts to exercise the new API.
- Register
/debug/pprof/heap/{seconds}route in the HTTP layer - Implement
dump_heap_pprofin the profiling component with tikv-jemalloc crates - Add two Python integration scripts for stress testing and requesting the new endpoint
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/server/src/http.rs | Register new pprof heap endpoint, map PprofHeap error variant |
| src/components/profile/src/lib.rs | Implement dump_heap_pprof, switch to tikv_jemalloc crates |
| src/components/profile/Cargo.toml | Update dependencies: add jemalloc_pprof, tikv-jemalloc-* |
| integration_tests/pprof_heap/stress.py | Add SQL workload stress test script (not directly pprof-related) |
| integration_tests/pprof_heap/request.py | Add script to fetch and save raw heap pprof data |
Comments suppressed due to low confidence (2)
src/server/src/http.rs:106
- [nitpick] The error message uses 'Fail to do heap pprof', which is awkward; consider rephrasing to 'Failed to dump heap pprof' for clarity and consistent tense.
#[snafu(display("Fail to do heap pprof, err:{}.\nBacktrace:\n{}", source, backtrace))]
src/components/profile/src/lib.rs:187
- The new
dump_heap_pprofmethod lacks unit tests to validate its behavior; consider adding tests to cover successful pprof dumps and error paths (e.g. uninitializedPROF_CTL).
pub fn dump_heap_pprof(&self, seconds: u64) -> Result<Vec<u8>> {
| warp::path!("debug" / "pprof" / "heap" / ..) | ||
| .and(warp::path::param::<u64>()) |
There was a problem hiding this comment.
[nitpick] Using .. in the warp::path! macro combined with a separate param can be error-prone; consider using warp::path!("debug" / "pprof" / "heap" / u64) to bind the segment directly for clearer routing.
| warp::path!("debug" / "pprof" / "heap" / ..) | |
| .and(warp::path::param::<u64>()) | |
| warp::path!("debug" / "pprof" / "heap" / u64) |
src/components/profile/src/lib.rs
Outdated
| let _guard = ProfLockGuard::new(lock_guard)?; | ||
|
|
||
| // wait for seconds for collect the profiling data | ||
| thread::sleep(time::Duration::from_secs(seconds)); |
There was a problem hiding this comment.
[nitpick] Since Duration is already imported, you can simplify this to thread::sleep(Duration::from_secs(seconds)); for consistency with existing imports.
| thread::sleep(time::Duration::from_secs(seconds)); | |
| thread::sleep(Duration::from_secs(seconds)); |
|
Saw the failing CI checks. Could be related to the changed |
|
@BaldDemian Please don't update this PR anymore, I will try fix those CI errors. |
|
@jiacai2050, thanks for your help! I tried fix these errors this morning but didn't succeed |


Rationale
Close #1577
Detailed Changes
src/server/src/http.rs, register the pprof api, similar to the existing/debug/profile/heap/{seconds}.src/components/profile/src/lib.rs, implementdump_heap_pproffunction, similar to the existingdump_heap_prof.Test Plan
Manual test. More details are given below.