Add dhat-heap feature

This commit is contained in:
dullbananas 2023-06-13 13:42:07 +00:00
parent 1aa2adf2f9
commit 08e835d487
4 changed files with 55 additions and 0 deletions

3
.gitignore vendored
View File

@ -26,3 +26,6 @@ pictrs/
# The generated typescript bindings
bindings
# Generated with dhat-heap feature enabled
dhat-*.json

43
Cargo.lock generated
View File

@ -1337,6 +1337,22 @@ dependencies = [
"serde",
]
[[package]]
name = "dhat"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f2aaf837aaf456f6706cb46386ba8dffd4013a757e36f4ea05c20dd46b209a3"
dependencies = [
"backtrace",
"lazy_static",
"mintex",
"parking_lot 0.12.1",
"rustc-hash",
"serde",
"serde_json",
"thousands",
]
[[package]]
name = "diesel"
version = "2.1.0"
@ -2745,6 +2761,7 @@ dependencies = [
"actix-web",
"clokwerk",
"console-subscriber",
"dhat",
"diesel",
"diesel-async",
"doku",
@ -3156,6 +3173,16 @@ dependencies = [
"adler",
]
[[package]]
name = "mintex"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd7c5ba1c3b5a23418d7bbf98c71c3d4946a0125002129231da8d6b723d559cb"
dependencies = [
"once_cell",
"sys-info",
]
[[package]]
name = "mio"
version = "0.8.4"
@ -5059,6 +5086,16 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8"
[[package]]
name = "sys-info"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "tap"
version = "1.0.1"
@ -5137,6 +5174,12 @@ dependencies = [
"syn 1.0.103",
]
[[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.4"

View File

@ -33,6 +33,7 @@ debug = 0
embed-pictrs = ["pict-rs"]
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"]
default = []
dhat-heap = ["dep:dhat"]
[workspace]
members = [
@ -140,3 +141,4 @@ opentelemetry-otlp = { version = "0.10.0", optional = true }
pict-rs = { version = "0.4.0-beta.9", optional = true }
tokio.workspace = true
actix-cors = "0.6.4"
dhat = { version = "0.3.2", optional = true }

View File

@ -1,8 +1,15 @@
use lemmy_server::{init_logging, start_lemmy_server};
use lemmy_utils::{error::LemmyError, settings::SETTINGS};
#[cfg(feature = "dhat-heap")]
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;
#[actix_web::main]
pub async fn main() -> Result<(), LemmyError> {
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::builder().trim_backtraces(None).build();
init_logging(&SETTINGS.opentelemetry_url)?;
#[cfg(not(feature = "embed-pictrs"))]
start_lemmy_server().await?;