From 5479f617ece4828a64e9eaf1b1751a68d2c64909 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 9 Dec 2025 10:40:48 +0000 Subject: [PATCH] Revert to jemalloc allocator --- .github/workflows/deploy-profiling.yaml | 82 ------------------------- .github/workflows/deploy.yaml | 7 +++ Cargo.lock | 6 -- Dockerfile | 5 +- README.md | 22 +++---- crates/alerter/Cargo.toml | 7 +-- crates/alerter/src/lib.rs | 2 +- crates/alerter/src/main.rs | 8 +-- crates/autopilot/Cargo.toml | 7 +-- crates/autopilot/src/main.rs | 8 +-- crates/autopilot/src/run.rs | 2 +- crates/driver/Cargo.toml | 7 +-- crates/driver/src/infra/observe/mod.rs | 2 +- crates/driver/src/main.rs | 8 +-- crates/observe/Cargo.toml | 3 +- crates/observe/src/heap_dump_handler.rs | 15 ++--- crates/observe/src/lib.rs | 2 +- crates/orderbook/Cargo.toml | 7 +-- crates/orderbook/src/main.rs | 8 +-- crates/orderbook/src/run.rs | 2 +- crates/refunder/Cargo.toml | 7 +-- crates/refunder/src/lib.rs | 2 +- crates/refunder/src/main.rs | 8 +-- crates/solvers/Cargo.toml | 7 +-- crates/solvers/src/main.rs | 8 +-- crates/solvers/src/run.rs | 2 +- 26 files changed, 74 insertions(+), 170 deletions(-) delete mode 100644 .github/workflows/deploy-profiling.yaml diff --git a/.github/workflows/deploy-profiling.yaml b/.github/workflows/deploy-profiling.yaml deleted file mode 100644 index ed218909ad..0000000000 --- a/.github/workflows/deploy-profiling.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: deploy-profiling -on: - workflow_dispatch: - inputs: - tag: - description: 'Tag suffix for the profiling image (e.g., "profiling" or "profiling-v1.2.3")' - required: false - default: 'profiling' - -jobs: - deploy-profiling: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - # Without this the fetch depth defaults to 1, which only includes the most recent commit. We want to know the full history so that `git describe` can give more information when it is invoked in the orderbook's crate build script. - fetch-depth: '0' - persist-credentials: false - - - uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set image tag - id: tag - run: | - if [ -n "${{ github.event.inputs.tag }}" ]; then - echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT - else - echo "tag=profiling" >> $GITHUB_OUTPUT - fi - echo "sha_tag=profiling-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT - - - name: Profiling services image metadata - id: meta_services - uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=raw,value=${{ steps.tag.outputs.tag }} - type=raw,value=${{ steps.tag.outputs.sha_tag }} - labels: | - org.opencontainers.image.licenses=GPL-3.0-or-later - org.opencontainers.image.description=CoW Protocol Services with jemalloc profiling enabled - - - name: Profiling services image build - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 - with: - context: . - file: Dockerfile - push: true - tags: ${{ steps.meta_services.outputs.tags }} - labels: ${{ steps.meta_services.outputs.labels }} - build-args: | - CARGO_BUILD_FEATURES=--features jemalloc-profiling - - - name: Profiling migration image metadata - id: meta_migration - uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 - with: - images: ghcr.io/${{ github.repository }}-migration - tags: | - type=raw,value=${{ steps.tag.outputs.tag }} - type=raw,value=${{ steps.tag.outputs.sha_tag }} - labels: | - org.opencontainers.image.licenses=GPL-3.0-or-later - - - name: Profiling migration image build - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 - with: - context: . - file: Dockerfile - target: migrations - push: true - tags: ${{ steps.meta_migration.outputs.tags }} - labels: ${{ steps.meta_migration.outputs.labels }} diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a5078d998a..53aefd3c69 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -4,6 +4,11 @@ on: branches: [main] tags: [v*] workflow_dispatch: + inputs: + features: + description: 'Optional cargo features (currently supported: "mimalloc-allocator")' + required: false + default: '' jobs: deploy: @@ -40,6 +45,8 @@ jobs: push: true tags: ${{ steps.meta_services.outputs.tags }} labels: ${{ steps.meta_services.outputs.labels }} + build-args: | + CARGO_BUILD_FEATURES=${{ github.event.inputs.features && format('--features {0}', github.event.inputs.features) || '' }} - name: Migration image metadata id: meta_migration diff --git a/Cargo.lock b/Cargo.lock index 566699c907..e71ab04f60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,7 +68,6 @@ dependencies = [ "anyhow", "clap", "humantime", - "jemalloc_pprof", "mimalloc", "model", "number", @@ -1217,7 +1216,6 @@ dependencies = [ "humantime", "indexmap 2.10.0", "itertools 0.14.0", - "jemalloc_pprof", "maplit", "mimalloc", "mockall 0.12.1", @@ -2725,7 +2723,6 @@ dependencies = [ "humantime-serde", "hyper 0.14.29", "itertools 0.14.0", - "jemalloc_pprof", "maplit", "mimalloc", "model", @@ -4870,7 +4867,6 @@ dependencies = [ "hex-literal", "humantime", "hyper 0.14.29", - "jemalloc_pprof", "mimalloc", "mockall 0.12.1", "model", @@ -5539,7 +5535,6 @@ dependencies = [ "futures", "gas-estimation", "humantime", - "jemalloc_pprof", "mimalloc", "number", "observe", @@ -6514,7 +6509,6 @@ dependencies = [ "hex-literal", "hyper 0.14.29", "itertools 0.14.0", - "jemalloc_pprof", "mimalloc", "model", "num", diff --git a/Dockerfile b/Dockerfile index 47e1b50a9c..6f622aae5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,10 +10,7 @@ ARG CARGO_BUILD_FEATURES="" # Install dependencies RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt-get update && \ - apt-get install -y git libssl-dev pkg-config && \ - if echo "${CARGO_BUILD_FEATURES}" | grep -q "jemalloc-profiling"; then \ - apt-get install -y build-essential; \ - fi + apt-get install -y git libssl-dev pkg-config build-essential # Install Rust toolchain RUN rustup install stable && rustup default stable diff --git a/README.md b/README.md index 08f54b679b..d8c13c0e79 100644 --- a/README.md +++ b/README.md @@ -113,28 +113,22 @@ tokio-console ## Heap Profiling -All binaries support opt-in heap profiling using jemalloc's profiling capabilities. This allows you to analyze memory usage in production environments without restarting services. +All binaries use jemalloc as the default memory allocator with built-in heap profiling support. Profiling is enabled at runtime via the `MALLOC_CONF` environment variable, allowing you to analyze memory usage in production environments without recompiling or restarting services. -### Building with Heap Profiling +**Note:** You can optionally use mimalloc instead of jemalloc by building with `--features mimalloc-allocator`, but this disables heap profiling capability. -Build with the `jemalloc-profiling` feature: -```bash -cargo build --release --features jemalloc-profiling -``` +### Enabling Heap Profiling -Or with Docker: +To enable heap profiling, run services with the `MALLOC_CONF` environment variable set: ```bash -docker build --build-arg CARGO_BUILD_FEATURES="--features jemalloc-profiling" . +MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:22" ``` -### Generating Heap Dumps +When profiling is enabled, each binary opens a UNIX socket at `/tmp/heap_dump_.sock`. -When running with the profiling feature enabled, each binary opens a UNIX socket at `/tmp/heap_dump_.sock`. To generate a heap dump, connect to the socket and send the "dump" command: +### Generating Heap Dumps -**Note:** Services must be run with the `MALLOC_CONF` environment variable set: -```bash -MALLOC_CONF="prof:true,prof_active:true,lg_prof_sample:19" -``` +Connect to the socket and send the "dump" command: ```bash # From Kubernetes diff --git a/crates/alerter/Cargo.toml b/crates/alerter/Cargo.toml index 86689a15c2..15f858e60b 100644 --- a/crates/alerter/Cargo.toml +++ b/crates/alerter/Cargo.toml @@ -11,9 +11,8 @@ anyhow = { workspace = true } clap = { workspace = true } humantime = { workspace = true } observe = { workspace = true } -mimalloc = { workspace = true } -tikv-jemallocator = { workspace = true, optional = true } -jemalloc_pprof = { workspace = true, optional = true } +mimalloc = { workspace = true, optional = true } +tikv-jemallocator = { workspace = true } model = { workspace = true } number = { workspace = true } prometheus = { workspace = true } @@ -30,4 +29,4 @@ warp = { workspace = true } workspace = true [features] -jemalloc-profiling = ["dep:tikv-jemallocator", "dep:jemalloc_pprof", "observe/jemalloc-profiling"] +mimalloc-allocator = ["dep:mimalloc"] diff --git a/crates/alerter/src/lib.rs b/crates/alerter/src/lib.rs index 2cf1f6d8d6..15d18a9c46 100644 --- a/crates/alerter/src/lib.rs +++ b/crates/alerter/src/lib.rs @@ -392,7 +392,7 @@ pub async fn start(args: impl Iterator) { ); observe::tracing::initialize(&obs_config); observe::panic_hook::install(); - #[cfg(all(unix, feature = "jemalloc-profiling"))] + #[cfg(unix)] observe::heap_dump_handler::spawn_heap_dump_handler(); observe::metrics::setup_registry(Some("gp_v2_alerter".to_string()), None); tracing::info!("running alerter with {:#?}", args); diff --git a/crates/alerter/src/main.rs b/crates/alerter/src/main.rs index ecc2d72ca7..ad082c219d 100644 --- a/crates/alerter/src/main.rs +++ b/crates/alerter/src/main.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "jemalloc-profiling")] +#[cfg(feature = "mimalloc-allocator")] #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(not(feature = "jemalloc-profiling"))] +#[cfg(not(feature = "mimalloc-allocator"))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[tokio::main] async fn main() { diff --git a/crates/autopilot/Cargo.toml b/crates/autopilot/Cargo.toml index 510c3ba404..6d6896c53a 100644 --- a/crates/autopilot/Cargo.toml +++ b/crates/autopilot/Cargo.toml @@ -39,9 +39,8 @@ humantime = { workspace = true } indexmap = { workspace = true } itertools = { workspace = true } maplit = { workspace = true } -mimalloc = { workspace = true } -tikv-jemallocator = { workspace = true, optional = true } -jemalloc_pprof = { workspace = true, optional = true } +mimalloc = { workspace = true, optional = true } +tikv-jemallocator = { workspace = true } model = { workspace = true } num = { workspace = true } number = { workspace = true } @@ -78,4 +77,4 @@ vergen = { workspace = true, features = ["git", "gitcl"] } workspace = true [features] -jemalloc-profiling = ["dep:tikv-jemallocator", "dep:jemalloc_pprof", "observe/jemalloc-profiling"] +mimalloc-allocator = ["dep:mimalloc"] diff --git a/crates/autopilot/src/main.rs b/crates/autopilot/src/main.rs index 9a05ca22bb..4597f2b554 100644 --- a/crates/autopilot/src/main.rs +++ b/crates/autopilot/src/main.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "jemalloc-profiling")] +#[cfg(feature = "mimalloc-allocator")] #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(not(feature = "jemalloc-profiling"))] +#[cfg(not(feature = "mimalloc-allocator"))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[tokio::main] async fn main() { diff --git a/crates/autopilot/src/run.rs b/crates/autopilot/src/run.rs index 5823554e7b..a8bc4420fb 100644 --- a/crates/autopilot/src/run.rs +++ b/crates/autopilot/src/run.rs @@ -146,7 +146,7 @@ pub async fn start(args: impl Iterator) { ); observe::tracing::initialize(&obs_config); observe::panic_hook::install(); - #[cfg(all(unix, feature = "jemalloc-profiling"))] + #[cfg(unix)] observe::heap_dump_handler::spawn_heap_dump_handler(); let commit_hash = option_env!("VERGEN_GIT_SHA").unwrap_or("COMMIT_INFO_NOT_FOUND"); diff --git a/crates/driver/Cargo.toml b/crates/driver/Cargo.toml index 89f59e8e53..fee5997cc6 100644 --- a/crates/driver/Cargo.toml +++ b/crates/driver/Cargo.toml @@ -35,9 +35,8 @@ humantime = { workspace = true } humantime-serde = { workspace = true } hyper = { workspace = true } itertools = { workspace = true } -mimalloc = { workspace = true } -tikv-jemallocator = { workspace = true, optional = true } -jemalloc_pprof = { workspace = true, optional = true } +mimalloc = { workspace = true, optional = true } +tikv-jemallocator = { workspace = true } moka = { workspace = true, features = ["future"] } num = { workspace = true } number = { workspace = true } @@ -93,4 +92,4 @@ vergen = { workspace = true, features = ["git", "gitcl"] } workspace = true [features] -jemalloc-profiling = ["dep:tikv-jemallocator", "dep:jemalloc_pprof", "observe/jemalloc-profiling"] +mimalloc-allocator = ["dep:mimalloc"] diff --git a/crates/driver/src/infra/observe/mod.rs b/crates/driver/src/infra/observe/mod.rs index a2e5d69b61..8d94fb30b1 100644 --- a/crates/driver/src/infra/observe/mod.rs +++ b/crates/driver/src/infra/observe/mod.rs @@ -38,7 +38,7 @@ pub mod metrics; pub fn init(obs_config: observe::Config) { observe::tracing::initialize_reentrant(&obs_config); metrics::init(); - #[cfg(all(unix, feature = "jemalloc-profiling"))] + #[cfg(unix)] observe::heap_dump_handler::spawn_heap_dump_handler(); } diff --git a/crates/driver/src/main.rs b/crates/driver/src/main.rs index bf43d356b4..ad758ab7fd 100644 --- a/crates/driver/src/main.rs +++ b/crates/driver/src/main.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "jemalloc-profiling")] +#[cfg(feature = "mimalloc-allocator")] #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(not(feature = "jemalloc-profiling"))] +#[cfg(not(feature = "mimalloc-allocator"))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[tokio::main] async fn main() { diff --git a/crates/observe/Cargo.toml b/crates/observe/Cargo.toml index ed98c00503..e72007e2d0 100644 --- a/crates/observe/Cargo.toml +++ b/crates/observe/Cargo.toml @@ -28,7 +28,7 @@ tracing-opentelemetry = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter", "fmt", "time"] } warp = { workspace = true } tracing-serde = { workspace = true } -jemalloc_pprof = { workspace = true, optional = true } +jemalloc_pprof = { workspace = true } [lints] workspace = true @@ -36,4 +36,3 @@ workspace = true [features] default = [] axum-tracing = ["axum"] -jemalloc-profiling = ["dep:jemalloc_pprof"] diff --git a/crates/observe/src/heap_dump_handler.rs b/crates/observe/src/heap_dump_handler.rs index da3b6992d7..e94282c713 100644 --- a/crates/observe/src/heap_dump_handler.rs +++ b/crates/observe/src/heap_dump_handler.rs @@ -11,6 +11,9 @@ use { /// When "dump" command is sent, it generates a heap profile using /// jemalloc_pprof and streams the binary protobuf data back through the socket. /// +/// Profiling is enabled at runtime via the MALLOC_CONF environment variable. +/// Set MALLOC_CONF=prof:true to enable heap profiling. +/// /// Usage: /// ```bash /// # From your local machine (one-liner): @@ -19,21 +22,19 @@ use { /// # Analyze with pprof: /// go tool pprof -http=:8080 heap.pprof /// ``` -#[cfg(all(unix, feature = "jemalloc-profiling"))] pub fn spawn_heap_dump_handler() { - // Check if jemalloc profiling is available before spawning the handler - // This prevents panics that would crash the entire process + // Check if jemalloc profiling is available at runtime + // This depends on whether MALLOC_CONF=prof:true was set let profiling_available = std::panic::catch_unwind(|| jemalloc_pprof::PROF_CTL.as_ref().is_some()).unwrap_or(false); if !profiling_available { - tracing::warn!( - "jemalloc profiling not available - heap dump handler not started. Ensure service is \ - built with jemalloc-profiling feature and MALLOC_CONF is set." - ); + // Profiling is disabled - do nothing return; } + tracing::info!("jemalloc heap profiling is active"); + tokio::spawn(async move { let name = binary_name().unwrap_or("unknown".to_string()); let socket_path = format!("/tmp/heap_dump_{name}.sock"); diff --git a/crates/observe/src/lib.rs b/crates/observe/src/lib.rs index 3ec2831204..e1993f79c0 100644 --- a/crates/observe/src/lib.rs +++ b/crates/observe/src/lib.rs @@ -4,7 +4,7 @@ pub mod config; pub mod distributed_tracing; pub mod future; -#[cfg(all(unix, feature = "jemalloc-profiling"))] +#[cfg(unix)] pub mod heap_dump_handler; pub mod metrics; pub mod panic_hook; diff --git a/crates/orderbook/Cargo.toml b/crates/orderbook/Cargo.toml index 33b09e7ae1..14c7e3c346 100644 --- a/crates/orderbook/Cargo.toml +++ b/crates/orderbook/Cargo.toml @@ -34,9 +34,8 @@ const-hex = { workspace = true } hex-literal = { workspace = true } humantime = { workspace = true } hyper = { workspace = true } -mimalloc = { workspace = true } -tikv-jemallocator = { workspace = true, optional = true } -jemalloc_pprof = { workspace = true, optional = true } +mimalloc = { workspace = true, optional = true } +tikv-jemallocator = { workspace = true } model = { workspace = true } multibase = { workspace = true } num = { workspace = true } @@ -73,4 +72,4 @@ workspace = true [features] e2e = [] -jemalloc-profiling = ["dep:tikv-jemallocator", "dep:jemalloc_pprof", "observe/jemalloc-profiling"] +mimalloc-allocator = ["dep:mimalloc"] diff --git a/crates/orderbook/src/main.rs b/crates/orderbook/src/main.rs index 0ed6dd3a83..89606ccc81 100644 --- a/crates/orderbook/src/main.rs +++ b/crates/orderbook/src/main.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "jemalloc-profiling")] +#[cfg(feature = "mimalloc-allocator")] #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(not(feature = "jemalloc-profiling"))] +#[cfg(not(feature = "mimalloc-allocator"))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[tokio::main] async fn main() { diff --git a/crates/orderbook/src/run.rs b/crates/orderbook/src/run.rs index 5b4d1bf795..cc9fd2f761 100644 --- a/crates/orderbook/src/run.rs +++ b/crates/orderbook/src/run.rs @@ -71,7 +71,7 @@ pub async fn start(args: impl Iterator) { tracing::info!("running order book with validated arguments:\n{}", args); observe::panic_hook::install(); observe::metrics::setup_registry(Some("gp_v2_api".into()), None); - #[cfg(all(unix, feature = "jemalloc-profiling"))] + #[cfg(unix)] observe::heap_dump_handler::spawn_heap_dump_handler(); run(args).await; } diff --git a/crates/refunder/Cargo.toml b/crates/refunder/Cargo.toml index 90468633a0..2117707822 100644 --- a/crates/refunder/Cargo.toml +++ b/crates/refunder/Cargo.toml @@ -17,9 +17,8 @@ futures = { workspace = true } gas-estimation = { workspace = true } const-hex = { workspace = true } humantime = { workspace = true } -mimalloc = { workspace = true } -tikv-jemallocator = { workspace = true, optional = true } -jemalloc_pprof = { workspace = true, optional = true } +mimalloc = { workspace = true, optional = true } +tikv-jemallocator = { workspace = true } number = { workspace = true } observe = { workspace = true } prometheus = { workspace = true } @@ -34,4 +33,4 @@ url = { workspace = true } workspace = true [features] -jemalloc-profiling = ["dep:tikv-jemallocator", "dep:jemalloc_pprof", "observe/jemalloc-profiling"] +mimalloc-allocator = ["dep:mimalloc"] diff --git a/crates/refunder/src/lib.rs b/crates/refunder/src/lib.rs index 2da3460276..f114bafaeb 100644 --- a/crates/refunder/src/lib.rs +++ b/crates/refunder/src/lib.rs @@ -30,7 +30,7 @@ pub async fn start(args: impl Iterator) { ); observe::tracing::initialize(&obs_config); observe::panic_hook::install(); - #[cfg(all(unix, feature = "jemalloc-profiling"))] + #[cfg(unix)] observe::heap_dump_handler::spawn_heap_dump_handler(); tracing::info!("running refunder with validated arguments:\n{}", args); observe::metrics::setup_registry(Some("refunder".into()), None); diff --git a/crates/refunder/src/main.rs b/crates/refunder/src/main.rs index 492ed93ce9..fa29490e76 100644 --- a/crates/refunder/src/main.rs +++ b/crates/refunder/src/main.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "jemalloc-profiling")] +#[cfg(feature = "mimalloc-allocator")] #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(not(feature = "jemalloc-profiling"))] +#[cfg(not(feature = "mimalloc-allocator"))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[tokio::main] async fn main() { diff --git a/crates/solvers/Cargo.toml b/crates/solvers/Cargo.toml index 6de8f230aa..e351085096 100644 --- a/crates/solvers/Cargo.toml +++ b/crates/solvers/Cargo.toml @@ -28,9 +28,8 @@ hex-literal = { workspace = true } hyper = { workspace = true } ethcontract = { workspace = true } itertools = { workspace = true } -mimalloc = { workspace = true } -tikv-jemallocator = { workspace = true, optional = true } -jemalloc_pprof = { workspace = true, optional = true } +mimalloc = { workspace = true, optional = true } +tikv-jemallocator = { workspace = true } num = { workspace = true } prometheus = { workspace = true } prometheus-metric-storage = { workspace = true } @@ -68,4 +67,4 @@ vergen = { workspace = true, features = ["git", "gitcl"] } workspace = true [features] -jemalloc-profiling = ["dep:tikv-jemallocator", "dep:jemalloc_pprof", "observe/jemalloc-profiling"] +mimalloc-allocator = ["dep:mimalloc"] diff --git a/crates/solvers/src/main.rs b/crates/solvers/src/main.rs index dc93d24e3a..03f6db6ca7 100644 --- a/crates/solvers/src/main.rs +++ b/crates/solvers/src/main.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "jemalloc-profiling")] +#[cfg(feature = "mimalloc-allocator")] #[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; -#[cfg(not(feature = "jemalloc-profiling"))] +#[cfg(not(feature = "mimalloc-allocator"))] #[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[tokio::main] async fn main() { diff --git a/crates/solvers/src/run.rs b/crates/solvers/src/run.rs index 3d5d48a016..41cd1b71c3 100644 --- a/crates/solvers/src/run.rs +++ b/crates/solvers/src/run.rs @@ -32,7 +32,7 @@ async fn run_with(args: cli::Args, bind: Option>) { None, ); observe::tracing::initialize_reentrant(&obs_config); - #[cfg(all(unix, feature = "jemalloc-profiling"))] + #[cfg(unix)] observe::heap_dump_handler::spawn_heap_dump_handler(); let commit_hash = option_env!("VERGEN_GIT_SHA").unwrap_or("COMMIT_INFO_NOT_FOUND");