-
Notifications
You must be signed in to change notification settings - Fork 222
feat: add pprof api #1627
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
feat: add pprof api #1627
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_pprof
in 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_pprof
method 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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) |
Copilot uses AI. Check for mistakes.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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)); |
Copilot uses AI. Check for mistakes.
Saw the failing CI checks. Could be related to the changed |
169cf4f
to
b5d9831
Compare
@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 |
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
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_pprof
function, similar to the existingdump_heap_prof
.Test Plan
Manual test. More details are given below.