Skip to content

Commit d2f4226

Browse files
adriangbdmontagu
andauthored
use default allocator for benchmarks (#662)
Co-authored-by: David Montague <[email protected]>
1 parent e7108e8 commit d2f4226

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.github/workflows/codspeed.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ jobs:
4646
- name: cache rust
4747
uses: Swatinem/rust-cache@v2
4848

49-
- run: pip install . -v
49+
- name: Install pydantic-core
50+
# build-prod does not include MiMalloc because it bypasses Maturin
51+
run: |
52+
pip install -e .
53+
make build-prod
54+
python -c 'import pydantic_core'
5055
env:
5156
CONST_RANDOM_SEED: 0 # Fix the compile time RNG seed
5257

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ crate-type = ["cdylib", "rlib"]
5151
extension-module = ["pyo3/extension-module"]
5252
# required for cargo bench
5353
auto-initialize = ["pyo3/auto-initialize"]
54-
default = ["mimalloc", "mimalloc/local_dynamic_tls", "pyo3/generate-import-lib", "pyo3/num-bigint"]
54+
# disabled for benchmarks since it makes microbenchmark performance more flakey
55+
mimalloc-allocator = ["mimalloc", "mimalloc/local_dynamic_tls"]
56+
default = ["pyo3/generate-import-lib", "pyo3/num-bigint"]
5557

5658
[profile.release]
5759
lto = "fat"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Source = 'https://github.com/pydantic/pydantic-core'
4646
[tool.maturin]
4747
module-name = "pydantic_core._pydantic_core"
4848
bindings = 'pyo3'
49-
features = ["pyo3/extension-module"]
49+
features = ["pyo3/extension-module", "mimalloc-allocator"]
5050

5151
[tool.ruff]
5252
line-length = 120

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate core;
55

66
use pyo3::prelude::*;
77

8-
#[cfg(feature = "mimalloc")]
8+
#[cfg(feature = "mimalloc-allocator")]
99
#[global_allocator]
1010
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
1111

0 commit comments

Comments
 (0)