Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion crates/sail-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ sail-telemetry = { path = "../sail-telemetry" }
sail-spark-connect = { path = "../sail-spark-connect" }
sail-session = { path = "../sail-session" }

mimalloc = { workspace = true, optional = true }
# TODO: Drop "v2" after:
# - libmimalloc-sys vendors the fix for https://github.com/microsoft/mimalloc/issues/1287 and
# - exposes MI_TLS_MODEL_LOCAL for macOS coexistence https://github.com/microsoft/mimalloc/issues/1301
mimalloc = { workspace = true, optional = true, features = ["v2"] }
clap = { workspace = true }
tokio = { workspace = true }
log = { workspace = true }
Expand Down
7 changes: 7 additions & 0 deletions crates/sail-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition = { workspace = true }
[lints]
workspace = true

[features]
mimalloc = ["dep:mimalloc"]

[dependencies]
sail-common = { path = "../sail-common" }
sail-common-datafusion = { path = "../sail-common-datafusion" }
Expand All @@ -22,6 +25,10 @@ sail-catalog-unity = { path = "../sail-catalog-unity" }

arrow-schema = { workspace = true }
bytes = { workspace = true }
# TODO: Drop "v2" after:
# - libmimalloc-sys vendors the fix for https://github.com/microsoft/mimalloc/issues/1287 and
# - exposes MI_TLS_MODEL_LOCAL for macOS coexistence https://github.com/microsoft/mimalloc/issues/1301
mimalloc = { workspace = true, optional = true, features = ["local_dynamic_tls", "v2"] }
pyo3 = { workspace = true }
tokio = { workspace = true }
log = { workspace = true }
Expand Down
9 changes: 9 additions & 0 deletions crates/sail-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ mod spark;

use pyo3::prelude::*;

// A `#[global_allocator]` only takes effect in the final linked artifact that compiles it in.
// The mimalloc static in `sail-cli` lives in its bin target (`main.rs`), so this
// cdylib does not inherit it (linking `sail-cli` as a lib causes no duplicate-allocator conflict).
// Without the static below, Rust code in the Python wheel falls back to the system allocator.
// This swaps the allocator for Rust allocations only; CPython's own allocator is untouched.
#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

/// Creates the `_native` Python module.
/// Registers the version constant, the `main` function,
/// and various submodules.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ python-source = "python"
module-name = "pysail._native"
manifest-path = "crates/sail-python/Cargo.toml"
features = [
"mimalloc",
"pyo3/extension-module",
"pyo3/abi3-py38",
"pyo3/generate-import-lib",
Expand Down
Loading