Skip to content

Commit 2a7c099

Browse files
committed
add snmalloc
1 parent c8fd910 commit 2a7c099

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
debug = false
88

99
[features]
10-
default = ["jemalloc"]
10+
default = []
1111
heed = ["dep:heed"]
1212
jemalloc = ["dep:jemallocator"]
1313
mimalloc = ["dep:mimalloc"]
@@ -16,6 +16,7 @@ sqlite = ["dep:rusqlite"]
1616
tcmalloc = ["dep:tcmalloc"]
1717
antithesis = ["dep:precept"]
1818
metrics = ["fjall_3/metrics"]
19+
snmalloc = ["dep:snmalloc"]
1920

2021
[target.'cfg(not(target_env = "msvc"))'.dependencies]
2122
jemallocator = { version = "0.5.4", optional = true }
@@ -54,3 +55,4 @@ r2d2 = "0.8.10"
5455
r2d2_sqlite = "0.31.0"
5556
format-bytes = "0.3.0"
5657
pretty-bytes = "0.2.2"
58+
snmalloc = { package = "snmalloc-rs", version = "0.1.0", optional = true }

src/db/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ impl DatabaseWrapper {
910910
#[cfg(feature = "metrics")]
911911
GenericDatabase::Fjall3 { tree, .. } => tree.inner().metrics().block_cache_hit_rate(),
912912

913+
#[cfg(feature = "rocksdb")]
913914
#[cfg(feature = "metrics")]
914915
GenericDatabase::RocksDb { tickers, opts, .. } => {
915916
let cache_hits = opts.get_ticker_count(tickers.block_cached) as f64;
@@ -925,6 +926,7 @@ impl DatabaseWrapper {
925926
/// % of filter queries that successfully filtered out superfluous I/O.
926927
pub fn filter_true_negative_ratio(&self) -> f64 {
927928
match &self.inner {
929+
#[cfg(feature = "metrics")]
928930
GenericDatabase::Fjall3 { tree, .. } => tree.inner().metrics().filter_efficiency(),
929931

930932
_ => 0.0,

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
3030
#[global_allocator]
3131
static GLOBAL: tcmalloc::TCMalloc = tcmalloc::TCMalloc;
3232

33+
#[cfg(feature = "snmalloc")]
34+
#[global_allocator]
35+
static ALLOC: snmalloc::SnMalloc = snmalloc::SnMalloc;
36+
3337
/// Gets the unix timestamp as a duration
3438
pub fn unix_timestamp() -> std::time::Duration {
3539
let now = std::time::SystemTime::now();

0 commit comments

Comments
 (0)