diff --git a/Cargo.lock b/Cargo.lock index 8650c6e9c1d..3301cb615c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10423,6 +10423,7 @@ dependencies = [ "bytes", "itertools 0.14.0", "log", + "mimalloc", "object_store", "parking_lot", "pyo3", diff --git a/vortex-python/Cargo.toml b/vortex-python/Cargo.toml index 60c1da60b4d..7a606495c7d 100644 --- a/vortex-python/Cargo.toml +++ b/vortex-python/Cargo.toml @@ -28,6 +28,10 @@ default = ["extension-module", "tui"] # duplicate PyInit__lib symbols. extension-module = [] tui = ["dep:vortex-tui"] +# Set the default allocator to mimalloc, this is enabled by default +# for the maturin wheels, but it is not a default feature to not conflict +# with users that set a different global allocator. +mimalloc = ["dep:mimalloc"] [dependencies] arrow-array = { workspace = true } @@ -36,6 +40,7 @@ arrow-schema = { workspace = true } bytes = { workspace = true } itertools = { workspace = true } log = { workspace = true } +mimalloc = { workspace = true, optional = true } object_store = { workspace = true, features = [ "fs", "aws", diff --git a/vortex-python/pyproject.toml b/vortex-python/pyproject.toml index e9699dee4fd..9e962667bf4 100644 --- a/vortex-python/pyproject.toml +++ b/vortex-python/pyproject.toml @@ -59,7 +59,7 @@ managed = true [tool.maturin] python-source = "python" module-name = "vortex._lib" -features = ["pyo3/extension-module"] +features = ["pyo3/extension-module", "mimalloc"] compatibility = "manylinux2014" include = [ { path = "rust-toolchain.toml", format = "sdist" }, diff --git a/vortex-python/src/lib.rs b/vortex-python/src/lib.rs index 1d6bd678a26..be399ea8d6e 100644 --- a/vortex-python/src/lib.rs +++ b/vortex-python/src/lib.rs @@ -1,6 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +#[cfg(feature = "mimalloc")] +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + use std::ops::Deref; use std::sync::LazyLock;