perf: switch to jemalloc allocator

This commit is contained in:
Greg Heartsfield 2023-05-07 19:32:50 -05:00
parent 2bcddf8bbf
commit 0582a891cc
3 changed files with 29 additions and 0 deletions

21
Cargo.lock generated
View File

@ -1689,6 +1689,7 @@ dependencies = [
"serde_json", "serde_json",
"sqlx", "sqlx",
"thiserror", "thiserror",
"tikv-jemallocator",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",
"tonic", "tonic",
@ -2958,6 +2959,26 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "tikv-jemalloc-sys"
version = "0.5.3+5.3.0-patched"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "tikv-jemallocator"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979"
dependencies = [
"libc",
"tikv-jemalloc-sys",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.45" version = "0.1.45"

View File

@ -54,6 +54,8 @@ bech32 = "0.9.1"
url = "2.3.1" url = "2.3.1"
qrcode = { version = "0.12.0", default-features = false, features = ["svg"] } qrcode = { version = "0.12.0", default-features = false, features = ["svg"] }
nostr = { version = "0.18.0", default-features = false, features = ["base", "nip04", "nip19"] } nostr = { version = "0.18.0", default-features = false, features = ["base", "nip04", "nip19"] }
[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = "0.5"
[dev-dependencies] [dev-dependencies]
anyhow = "1" anyhow = "1"

View File

@ -8,6 +8,12 @@ use std::sync::mpsc as syncmpsc;
use std::sync::mpsc::{Receiver as MpscReceiver, Sender as MpscSender}; use std::sync::mpsc::{Receiver as MpscReceiver, Sender as MpscSender};
use std::thread; use std::thread;
use tracing::info; use tracing::info;
#[cfg(not(target_env = "msvc"))]
use tikv_jemallocator::Jemalloc;
#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
/// Start running a Nostr relay server. /// Start running a Nostr relay server.
fn main() { fn main() {