Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
Signed-off-by: Calvin Neo <[email protected]>
  • Loading branch information
CalvinNeo committed Aug 23, 2024
1 parent 1eebaf1 commit ae0f308
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
44 changes: 36 additions & 8 deletions proxy_components/proxy_server/src/status_server/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,48 @@ pub fn read_file(path: &str) -> Result<Vec<u8>, String> {

pub fn jeprof_heap_profile(path: &str, output_format: String) -> Result<Vec<u8>, String> {
let bin = std::env::current_exe().map_err(|e| format!("get current exe path fail: {}", e))?;
let mut bin_proxy = bin.clone();
let mut bin_proxy_str = String::from("");
if bin_proxy.pop() {
bin_proxy.push("libtiflash_proxy.so");
if let Some(s) = &bin_proxy.to_str() {
if std::path::Path::new(s).exists() {
bin_proxy_str = s.to_string();
}
}
}
let bin_str = &bin.as_os_str().to_string_lossy();
info!(
"using jeprof to process {} bin {} exist {}",
"using jeprof to process {} bin {} bin_proxy {} exist {}",
path,
bin_str,
bin_proxy_str,
std::path::Path::new(path).exists()
);
let mut jeprof = Command::new("perl")
.args(["/dev/stdin", "--show_bytes", bin_str, path, &output_format])
.stdin(Stdio::piped())
.stderr(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.map_err(|e| format!("spawn jeprof fail: {}", e))?;
let mut jeprof = if !bin_proxy_str.is_empty() {
Command::new("perl")
.args([
"/dev/stdin",
"--show_bytes",
bin_str,
path,
&output_format,
&format!("--add_lib={}", bin_proxy_str),
])
.stdin(Stdio::piped())
.stderr(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.map_err(|e| format!("spawn jeprof fail: {}", e))
} else {
Command::new("perl")
.args(["/dev/stdin", "--show_bytes", bin_str, path, &output_format])
.stdin(Stdio::piped())
.stderr(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.map_err(|e| format!("spawn jeprof fail: {}", e))
}?;
jeprof
.stdin
.take()
Expand Down
2 changes: 2 additions & 0 deletions proxy_tests/proxy/shared/fast_add_peer/fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ fn test_msgsnapshot_before_msgappend() {

pd_client.must_add_peer(1, new_learner_peer(2, 2));

std::thread::sleep(std::time::Duration::from_secs(1));

iter_ffi_helpers(&cluster, Some(vec![2]), &mut |_, ffi: &mut FFIHelperSet| {
let mut x: u64 = 0;
let mut y: u64 = 0;
Expand Down

0 comments on commit ae0f308

Please sign in to comment.