forked from tikv/tikv
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Enable heap profiling #376
Merged
ti-chi-bot
merged 3 commits into
pingcap:raftstore-proxy
from
CalvinNeo:enable-heap-prof
Jul 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
50 changes: 50 additions & 0 deletions
50
proxy_components/proxy_server/src/status_server/vendored_utils.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
use proxy_ffi::jemalloc_utils::issue_mallctl_args; | ||
use tikv_alloc::error::ProfResult; | ||
|
||
pub fn activate_prof() -> ProfResult<()> { | ||
{ | ||
let mut value: bool = true; | ||
let mut len = std::mem::size_of_val(&value) as u64; | ||
issue_mallctl_args( | ||
"prof.active", | ||
&mut value as *mut _ as *mut _, | ||
&mut len, | ||
&mut value as *mut _ as *mut _, | ||
len, | ||
); | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub fn deactivate_prof() -> ProfResult<()> { | ||
{ | ||
let mut value: bool = false; | ||
let mut len = std::mem::size_of_val(&value) as u64; | ||
issue_mallctl_args( | ||
"prof.active", | ||
&mut value as *mut _ as *mut _, | ||
&mut len, | ||
&mut value as *mut _ as *mut _, | ||
len, | ||
); | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub fn dump_prof(path: &str) -> tikv_alloc::error::ProfResult<()> { | ||
{ | ||
let mut bytes = std::ffi::CString::new(path)?.into_bytes_with_nul(); | ||
let mut ptr = bytes.as_mut_ptr() as *mut ::std::os::raw::c_char; | ||
let len = std::mem::size_of_val(&ptr) as u64; | ||
issue_mallctl_args( | ||
"prof.dump", | ||
std::ptr::null_mut(), | ||
std::ptr::null_mut(), | ||
&mut ptr as *mut _ as *mut _, | ||
len, | ||
); | ||
} | ||
Ok(()) | ||
} |
Oops, something went wrong.
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.
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.
I think we should allocate another local value for storing the "old_value" get from mallctl
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.
Copied from https://github.com/tikv/jemallocator/blob/e9692ae34cd2e8d888f416c26eb1664a093807d9/jemalloc-ctl/src/raw.rs#L188
See also https://github.com/tikv/tikv/blob/9fb4aaac9bfe07db066e99397b56384d7a92b3e0/components/tikv_alloc/src/jemalloc.rs#L330
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.
Changed to "write" mode