Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--Cargo.lock1
-rw-r--r--crates/profile/Cargo.toml1
-rw-r--r--crates/profile/src/memory_usage.rs15
3 files changed, 8 insertions, 9 deletions
diff --git a/Cargo.lock b/Cargo.lock
index cbbeef0030..0606ad81ba 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1939,7 +1939,6 @@ dependencies = [
name = "profile"
version = "0.0.0"
dependencies = [
- "cfg-if",
"libc",
"perf-event",
"tikv-jemalloc-ctl",
diff --git a/crates/profile/Cargo.toml b/crates/profile/Cargo.toml
index 048d3776ca..2cffb269fd 100644
--- a/crates/profile/Cargo.toml
+++ b/crates/profile/Cargo.toml
@@ -13,7 +13,6 @@ rust-version.workspace = true
doctest = false
[dependencies]
-cfg-if = "1.0.1"
jemalloc-ctl = { version = "0.5.4", package = "tikv-jemalloc-ctl", optional = true }
[target.'cfg(all(target_os = "linux", not(target_env = "ohos"), any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))'.dependencies]
diff --git a/crates/profile/src/memory_usage.rs b/crates/profile/src/memory_usage.rs
index 1462259d62..a8a409bd46 100644
--- a/crates/profile/src/memory_usage.rs
+++ b/crates/profile/src/memory_usage.rs
@@ -3,8 +3,6 @@
//! Measures the total size of all currently allocated objects.
use std::fmt;
-use cfg_if::cfg_if;
-
#[derive(Copy, Clone)]
pub struct MemoryUsage {
pub allocated: Bytes,
@@ -25,15 +23,17 @@ impl std::ops::Sub for MemoryUsage {
impl MemoryUsage {
pub fn now() -> MemoryUsage {
- cfg_if! {
- if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] {
+ cfg_select! {
+ all(feature = "jemalloc", not(target_env = "msvc")) => {
jemalloc_ctl::epoch::advance().unwrap();
MemoryUsage {
allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap() as isize),
}
- } else if #[cfg(all(target_os = "linux", target_env = "gnu"))] {
+ }
+ all(target_os = "linux", target_env = "gnu") => {
memusage_linux()
- } else if #[cfg(windows)] {
+ }
+ windows => {
// There doesn't seem to be an API for determining heap usage, so we try to
// approximate that by using the Commit Charge value.
@@ -48,7 +48,8 @@ impl MemoryUsage {
let usage = unsafe { mem_counters.assume_init().PagefileUsage };
MemoryUsage { allocated: Bytes(usage as isize) }
- } else {
+ }
+ _ => {
MemoryUsage { allocated: Bytes(0) }
}
}