Skip to content

Commit 5f75b2f

Browse files
committed
fix write_thread_name_fallback and bench addr_validate
1 parent c855009 commit 5f75b2f

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

benches/addr_validate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
22

33
use criterion::{criterion_group, criterion_main, Criterion};
4-
use pprof::validate;
4+
use pprof::addr_validate;
55

66
fn bench_validate_addr(c: &mut Criterion) {
77
c.bench_function("validate stack addr", |b| {
88
let stack_addrs = [0; 100];
99

1010
b.iter(|| {
1111
stack_addrs.iter().for_each(|item| {
12-
validate(item as *const _ as *const libc::c_void);
12+
addr_validate(item as *const _ as *const libc::c_void);
1313
})
1414
})
1515
});
@@ -19,7 +19,7 @@ fn bench_validate_addr(c: &mut Criterion) {
1919

2020
b.iter(|| {
2121
heap_addrs.iter().for_each(|item| {
22-
validate(item as *const _ as *const libc::c_void);
22+
addr_validate(item as *const _ as *const libc::c_void);
2323
})
2424
})
2525
});

src/platform/nix_impl/profiler.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl ProfilerImpl for Profiler {
3232

3333
#[cfg(not(all(any(target_os = "linux", target_os = "macos"), target_env = "gnu")))]
3434
fn write_thread_name(current_thread: libc::pthread_t, name: &mut [libc::c_char]) {
35-
crate::profiler::write_thread_name_fallback(current_thread, name);
35+
write_thread_name_fallback(current_thread as usize as u128, name);
3636
}
3737

3838
#[cfg(all(any(target_os = "linux", target_os = "macos"), target_env = "gnu"))]
@@ -41,7 +41,7 @@ fn write_thread_name(current_thread: libc::pthread_t, name: &mut [libc::c_char])
4141
let ret = unsafe { libc::pthread_getname_np(current_thread, name_ptr, MAX_THREAD_NAME) };
4242

4343
if ret != 0 {
44-
write_thread_name_fallback(current_thread, name);
44+
write_thread_name_fallback(current_thread as usize as u128, name);
4545
}
4646
}
4747

src/profiler.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ use crate::{MAX_DEPTH, MAX_THREAD_NAME};
2121
pub(crate) static PROFILER: Lazy<RwLock<Result<Profiler>>> =
2222
Lazy::new(|| RwLock::new(Profiler::new()));
2323

24-
pub fn write_thread_name_fallback<T: Into<u128>>(thread: T, name: &mut [libc::c_char]) {
24+
pub fn write_thread_name_fallback(thread: u128, name: &mut [libc::c_char]) {
2525
let mut len = 0;
2626
let mut base = 1;
2727

28-
let thread: u128 = thread.into();
2928
while thread > base && len < MAX_THREAD_NAME {
3029
base *= 10;
3130
len += 1;

0 commit comments

Comments
 (0)