fix: add dhat

This commit is contained in:
monosans
2025-09-18 11:42:17 +03:00
parent edf06a7281
commit 509e7acacc
3 changed files with 57 additions and 2 deletions
Generated
+37 -2
View File
@@ -408,6 +408,22 @@ version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
[[package]]
name = "dhat"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98cd11d84628e233de0ce467de10b8633f4ddaecafadefc86e13b84b8739b827"
dependencies = [
"backtrace",
"lazy_static",
"mintex",
"parking_lot",
"rustc-hash 1.1.0",
"serde",
"serde_json",
"thousands",
]
[[package]]
name = "dirs"
version = "6.0.0"
@@ -1296,6 +1312,12 @@ dependencies = [
"adler2",
]
[[package]]
name = "mintex"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c505b3e17ed6b70a7ed2e67fbb2c560ee327353556120d6e72f5232b6880d536"
[[package]]
name = "mio"
version = "1.0.4"
@@ -1463,6 +1485,7 @@ dependencies = [
"async-trait",
"color-eyre",
"crossterm",
"dhat",
"dirs",
"fancy-regex",
"foldhash 0.2.0",
@@ -1501,7 +1524,7 @@ dependencies = [
"pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash",
"rustc-hash 2.1.1",
"rustls",
"socket2 0.6.0",
"thiserror 2.0.16",
@@ -1521,7 +1544,7 @@ dependencies = [
"lru-slab",
"rand",
"ring",
"rustc-hash",
"rustc-hash 2.1.1",
"rustls",
"rustls-pki-types",
"slab",
@@ -1753,6 +1776,12 @@ version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc-hash"
version = "2.1.1"
@@ -2131,6 +2160,12 @@ dependencies = [
"syn",
]
[[package]]
name = "thousands"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820"
[[package]]
name = "thread_local"
version = "1.1.9"
+7
View File
@@ -11,6 +11,7 @@ color-eyre = "=0.6.5"
crossterm = { version = "=0.28.1", features = [
"event-stream",
], optional = true }
dhat = { version = "=0.3.3", optional = true }
dirs = "=6.0.0"
fancy-regex = "=0.16.1"
foldhash = "=0.2.0"
@@ -51,6 +52,7 @@ url = "=2.5.7"
mimalloc = { version = "=0.1.48", optional = true, features = ["v3"] }
[features]
dhat = ["dep:dhat"]
mimalloc = ["dep:mimalloc"]
tui = ["dep:crossterm", "dep:futures", "dep:ratatui", "dep:tui-logger"]
@@ -58,3 +60,8 @@ tui = ["dep:crossterm", "dep:futures", "dep:ratatui", "dep:tui-logger"]
strip = true
lto = "fat"
codegen-units = 1
[profile.dhat]
inherits = "release"
debug = true
strip = "none"
+13
View File
@@ -47,6 +47,12 @@
clippy::unwrap_used
)]
#[cfg(all(feature = "dhat", feature = "mimalloc"))]
compile_error!(
"Features 'dhat-heap' and 'mimalloc' are mutually exclusive. Enable only \
one."
);
mod checker;
mod config;
#[cfg(feature = "tui")]
@@ -69,6 +75,10 @@ use tracing_subscriber::{
layer::SubscriberExt as _, util::SubscriberInitExt as _,
};
#[cfg(feature = "dhat")]
#[global_allocator]
static GLOBAL: dhat::Alloc = dhat::Alloc;
#[cfg(all(
feature = "mimalloc",
any(target_arch = "aarch64", target_arch = "x86_64"),
@@ -314,6 +324,9 @@ async fn run_without_tui(
#[tokio::main]
#[expect(clippy::unwrap_in_result)]
async fn main() -> crate::Result<()> {
#[cfg(feature = "dhat")]
let _profiler = dhat::Profiler::new_heap();
color_eyre::install().wrap_err("failed to install color_eyre hooks")?;
let config = config::load_config().await?;