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 # The generated typescript bindings
bindings bindings
# Generated with dhat-heap feature enabled
dhat-*.json

43
Cargo.lock generated
View file

@ -1337,6 +1337,22 @@ dependencies = [
"serde", "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]] [[package]]
name = "diesel" name = "diesel"
version = "2.1.0" version = "2.1.0"
@ -2745,6 +2761,7 @@ dependencies = [
"actix-web", "actix-web",
"clokwerk", "clokwerk",
"console-subscriber", "console-subscriber",
"dhat",
"diesel", "diesel",
"diesel-async", "diesel-async",
"doku", "doku",
@ -3156,6 +3173,16 @@ dependencies = [
"adler", "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]] [[package]]
name = "mio" name = "mio"
version = "0.8.4" version = "0.8.4"
@ -5059,6 +5086,16 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" 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]] [[package]]
name = "tap" name = "tap"
version = "1.0.1" version = "1.0.1"
@ -5137,6 +5174,12 @@ dependencies = [
"syn 1.0.103", "syn 1.0.103",
] ]
[[package]]
name = "thousands"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820"
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.4" version = "1.1.4"

View file

@ -33,6 +33,7 @@ debug = 0
embed-pictrs = ["pict-rs"] embed-pictrs = ["pict-rs"]
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"] console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"]
default = [] default = []
dhat-heap = ["dep:dhat"]
[workspace] [workspace]
members = [ members = [
@ -140,3 +141,4 @@ opentelemetry-otlp = { version = "0.10.0", optional = true }
pict-rs = { version = "0.4.0-beta.9", optional = true } pict-rs = { version = "0.4.0-beta.9", optional = true }
tokio.workspace = true tokio.workspace = true
actix-cors = "0.6.4" 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_server::{init_logging, start_lemmy_server};
use lemmy_utils::{error::LemmyError, settings::SETTINGS}; use lemmy_utils::{error::LemmyError, settings::SETTINGS};
#[cfg(feature = "dhat-heap")]
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;
#[actix_web::main] #[actix_web::main]
pub async fn main() -> Result<(), LemmyError> { pub async fn main() -> Result<(), LemmyError> {
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::builder().trim_backtraces(None).build();
init_logging(&SETTINGS.opentelemetry_url)?; init_logging(&SETTINGS.opentelemetry_url)?;
#[cfg(not(feature = "embed-pictrs"))] #[cfg(not(feature = "embed-pictrs"))]
start_lemmy_server().await?; start_lemmy_server().await?;