Skip to content

Commit

Permalink
chore: Use jemalloc global allocator on supported platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
jbencin committed Feb 11, 2024
1 parent 606838d commit bc57f72
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
wsts = { version = "8.0", default-features = false }
rand_core = "0.6"
rand = "0.8"
tikv-jemallocator = "0.5.4"

# Use a bit more than default optimization for
# dev builds to speed up test execution
Expand Down
3 changes: 3 additions & 0 deletions stackslib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ wsts = {workspace = true}
rand_core = {workspace = true}
hashbrown = "0.14"

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = {workspace = true}

[target.'cfg(unix)'.dependencies]
nix = "0.23"

Expand Down
7 changes: 7 additions & 0 deletions stackslib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ extern crate stacks_common;
#[macro_use(o, slog_log, slog_trace, slog_debug, slog_info, slog_warn, slog_error)]
extern crate slog;

#[cfg(not(target_env = "msvc"))]
use tikv_jemallocator::Jemalloc;

#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;

use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use std::fs::{File, OpenOptions};
Expand Down
3 changes: 3 additions & 0 deletions testnet/stacks-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ rand = { workspace = true }
rand_core = { workspace = true }
hashbrown = "0.14"

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = {workspace = true}

[dev-dependencies]
ring = "0.16.19"
warp = "0.3.5"
Expand Down
7 changes: 7 additions & 0 deletions testnet/stacks-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ use crate::mockamoto::MockamotoNode;
use crate::neon_node::{BlockMinerThread, TipCandidate};
use crate::run_loop::boot_nakamoto;

#[cfg(not(target_env = "msvc"))]
use tikv_jemallocator::Jemalloc;

#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;

/// Implmentation of `pick_best_tip` CLI option
fn cli_pick_best_tip(config_path: &str, at_stacks_height: Option<u64>) -> TipCandidate {
info!("Loading config at path {}", config_path);
Expand Down

0 comments on commit bc57f72

Please sign in to comment.