Skip to content

Commit ce2068f

Browse files
authored
Replace MiMalloc w/ default allocator (#900)
1 parent 5f7426d commit ce2068f

File tree

5 files changed

+4
-47
lines changed

5 files changed

+4
-47
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,11 @@ jobs:
396396
- os: ubuntu
397397
platform: linux
398398
target: aarch64
399-
# mimalloc not supported on manylinux2014 cross-compile container
400-
extra-build-args: --no-default-features
399+
401400
- os: ubuntu
402401
platform: linux
403402
target: armv7
404403
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12
405-
# mimalloc not supported on manylinux2014 cross-compile container
406-
extra-build-args: --no-default-features
407404
# musllinux
408405
- os: ubuntu
409406
platform: linux
@@ -417,14 +414,10 @@ jobs:
417414
platform: linux
418415
target: ppc64le
419416
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12
420-
# mimalloc not supported on manylinux2014 cross-compile container
421-
extra-build-args: --no-default-features
422417
- os: ubuntu
423418
platform: linux
424419
target: s390x
425420
interpreter: 3.7 3.8 3.9 3.10 3.11 3.12
426-
# mimalloc not supported on manylinux2014 cross-compile container
427-
extra-build-args: --no-default-features
428421
exclude:
429422
# Optimized PGO builds for x86_64 manylinux and windows follow a different matrix,
430423
# maybe in future maturin-action can support this automatically

‎.github/workflows/codspeed.yml‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ jobs:
5050
uses: Swatinem/rust-cache@v2
5151

5252
- name: Compile pydantic-core for profiling
53-
# --no-default-features to avoid using mimalloc
5453
run: |
55-
pip install -e . --config-settings=build-args='--no-default-features --verbose' -v
56-
python -c 'import pydantic_core; assert pydantic_core._pydantic_core.__pydantic_core_default_allocator__'
54+
pip install -e . --config-settings=build-args='--verbose' -v
5755
env:
5856
CONST_RANDOM_SEED: 0 # Fix the compile time RNG seed
5957
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/profdata"
@@ -65,10 +63,8 @@ jobs:
6563
run: rustup run stable bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'
6664

6765
- name: Compile pydantic-core for benchmarking
68-
# --no-default-features to avoid using mimalloc
6966
run: |
70-
pip install -e . --config-settings=build-args='--no-default-features --verbose' -v
71-
python -c 'import pydantic_core; assert pydantic_core._pydantic_core.__pydantic_core_default_allocator__'
67+
pip install -e . --config-settings=build-args='--verbose' -v
7268
env:
7369
CONST_RANDOM_SEED: 0 # Fix the compile time RNG seed
7470
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"

‎Cargo.lock‎

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ strum_macros = "0.25.2"
3333
serde_json = {version = "1.0.104", features = ["arbitrary_precision", "preserve_order"]}
3434
enum_dispatch = "0.3.8"
3535
serde = { version = "1.0.183", features = ["derive"] }
36-
# disabled for benchmarks since it makes microbenchmark performance more flakey
37-
mimalloc = { version = "0.1.30", optional = true, default-features = false, features = ["local_dynamic_tls"] }
3836
speedate = "0.12.0"
3937
smallvec = "1.11.0"
4038
ahash = "0.8.0"
@@ -53,7 +51,6 @@ crate-type = ["cdylib", "rlib"]
5351
[features]
5452
# must be enabled when building with `cargo build`, maturin enables this automatically
5553
extension-module = ["pyo3/extension-module"]
56-
default = ["mimalloc"]
5754

5855
[profile.release]
5956
lto = "fat"

‎src/lib.rs‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ use std::sync::OnceLock;
66

77
use pyo3::{prelude::*, sync::GILOnceCell};
88

9-
#[cfg(feature = "mimalloc")]
10-
#[global_allocator]
11-
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
12-
139
// parse this first to get access to the contained macro
1410
#[macro_use]
1511
mod py_gc;
@@ -69,10 +65,9 @@ fn get_pydantic_version(py: Python<'_>) -> Option<&'static str> {
6965

7066
pub fn build_info() -> String {
7167
format!(
72-
"profile={} pgo={} mimalloc={}",
68+
"profile={} pgo={}",
7369
env!("PROFILE"),
7470
option_env!("RUSTFLAGS").unwrap_or("").contains("-Cprofile-use="),
75-
cfg!(feature = "mimalloc")
7671
)
7772
}
7873

@@ -102,9 +97,5 @@ fn _pydantic_core(py: Python, m: &PyModule) -> PyResult<()> {
10297
m.add_function(wrap_pyfunction!(to_json, m)?)?;
10398
m.add_function(wrap_pyfunction!(to_jsonable_python, m)?)?;
10499
m.add_function(wrap_pyfunction!(list_all_errors, m)?)?;
105-
106-
#[cfg(not(feature = "mimalloc"))]
107-
m.setattr("__pydantic_core_default_allocator__", true)?; // uses setattr so this is not in __all__
108-
109100
Ok(())
110101
}

0 commit comments

Comments
 (0)