-
Notifications
You must be signed in to change notification settings - Fork 419
feat: add HTTP endpoint to control prof.gdump feature #6999
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
base: main
Are you sure you want to change the base?
Conversation
### Add Support for Jemalloc Gdump Flag - **`jemalloc.rs`**: Introduced `PROF_GDUMP` constant and added functions `set_gdump_active` and `is_gdump_active` to manage the gdump flag. - **`error.rs`**: Added error handling for reading and updating the jemalloc gdump flag with `ReadGdump` and `UpdateGdump` errors. - **`lib.rs`**: Exposed `is_gdump_active` and `set_gdump_active` functions for non-Windows platforms. - **`http.rs`**: Added HTTP routes for checking and toggling the jemalloc gdump flag status. - **`mem_prof.rs`**: Implemented handlers `gdump_toggle_handler` and `gdump_status_handler` for managing gdump flag via HTTP requests. Signed-off-by: Lei, HUANG <[email protected]>
Co-authored-by: shuiyisong <[email protected]>
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.
Others LGTM
use crate::error::DumpProfileDataSnafu; | ||
|
||
let is_active = common_mem_prof::is_gdump_active().context(DumpProfileDataSnafu)?; | ||
Ok((StatusCode::OK, format!("{{\"active\": {}}}", is_active))) |
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.
Nit: use serde_json::json! ?
curl -X POST localhost:4000/debug/prof/mem/deactivate | ||
|
||
# Activate gdump feature that dumps memory profiling data every time virtual memory usage exceeds previous maximum value. | ||
`curl -X POST localhost:4000/debug/prof/mem/gdump -d 'activate=true'` |
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.
`curl -X POST localhost:4000/debug/prof/mem/gdump -d 'activate=true'` | |
curl -X POST localhost:4000/debug/prof/mem/gdump -d 'activate=true' |
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
prof.gdump
is a convenient features provided by jemalloc that dumps the memory profiling data every time the memory usage exceeds previous maximum value. This PR adds an HTTP endpoint to control the status ofprof.gdump
.Add Support for Jemalloc Gdump Flag
jemalloc.rs
: IntroducedPROF_GDUMP
constant and added functionsset_gdump_active
andis_gdump_active
to manage the gdump flag.error.rs
: Added error handling for reading and updating the jemalloc gdump flag withReadGdump
andUpdateGdump
errors.lib.rs
: Exposedis_gdump_active
andset_gdump_active
functions for non-Windows platforms.http.rs
: Added HTTP routes for checking and toggling the jemalloc gdump flag status.mem_prof.rs
: Implemented handlersgdump_toggle_handler
andgdump_status_handler
for managing gdump flag via HTTP requests.PR Checklist
Please convert it to a draft if some of the following conditions are not met.