Gate jemalloc behind feature (#618)
Some checks are pending
test / linux (3.11) (push) Waiting to run
test / linux (3.10) (push) Waiting to run
test / macos (3.9) (push) Waiting to run
test / linux (3.12) (push) Waiting to run
test / linux (3.13) (push) Waiting to run
test / linux (3.14) (push) Waiting to run
test / linux (3.9) (push) Waiting to run
test / linux (pypy3.11) (push) Waiting to run
test / linux (3.13t) (push) Waiting to run
test / linux (3.14t) (push) Waiting to run
test / macos (3.10) (push) Waiting to run
test / macos (3.11) (push) Waiting to run
test / macos (3.12) (push) Waiting to run
test / macos (3.13) (push) Waiting to run
test / macos (3.14) (push) Waiting to run
test / macos (3.13t) (push) Waiting to run
test / macos (3.14t) (push) Waiting to run
test / windows (3.10) (push) Waiting to run
test / windows (3.11) (push) Waiting to run
test / windows (3.12) (push) Waiting to run
test / windows (3.13) (push) Waiting to run
test / windows (3.13t) (push) Waiting to run
test / windows (3.14) (push) Waiting to run
test / windows (3.14t) (push) Waiting to run
test / windows (3.9) (push) Waiting to run

This commit is contained in:
Giovanni Barillari 2025-06-27 19:24:14 +02:00 committed by GitHub
parent 010d364b79
commit 52de19afd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 60 deletions

View file

@ -11,10 +11,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu, macos, windows] os: [ubuntu, macos]
target: [x86_64, aarch64] target: [x86_64, aarch64]
manylinux: [auto] manylinux: [auto]
allocator: [auto] allocator: [jemalloc]
include: include:
- os: ubuntu - os: ubuntu
platform: linux platform: linux
@ -29,6 +29,7 @@ jobs:
platform: linux platform: linux
target: i686 target: i686
interpreter: 3.9 3.10 3.11 3.12 3.13 3.14 interpreter: 3.9 3.10 3.11 3.12 3.13 3.14
allocator: jemalloc
- os: ubuntu - os: ubuntu
platform: linux platform: linux
target: aarch64 target: aarch64
@ -46,6 +47,7 @@ jobs:
platform: linux platform: linux
target: armv7 target: armv7
interpreter: 3.9 3.10 3.11 3.12 3.13 3.14 interpreter: 3.9 3.10 3.11 3.12 3.13 3.14
allocator: jemalloc
- os: ubuntu - os: ubuntu
platform: linux platform: linux
target: x86_64 target: x86_64
@ -77,14 +79,8 @@ jobs:
allocator: mimalloc allocator: mimalloc
- os: windows - os: windows
target: x86_64 target: x86_64
interpreter: 3.9 3.10 3.11 3.12 3.13 3.14 pypy3.9 pypy3.10 pypy3.11 interpreter: 3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11
- os: windows
target: x86_64
interpreter: 3.13t 3.14t
allocator: mimalloc allocator: mimalloc
exclude:
- os: windows
target: aarch64
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest
steps: steps:
@ -94,21 +90,10 @@ jobs:
run: | run: |
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
- uses: pyo3/maturin-action@v1 - uses: pyo3/maturin-action@v1
if: matrix.allocator != 'mimalloc'
with: with:
rust-toolchain: stable rust-toolchain: stable
command: build command: build
args: --release --out dist --interpreter ${{ matrix.interpreter || env.PY_ALL }} args: --release --out dist --features ${{ matrix.allocator }} --interpreter ${{ matrix.interpreter || env.PY_ALL }}
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
container: ${{ matrix.container }}
docker-options: -e CI
- uses: pyo3/maturin-action@v1
if: matrix.allocator == 'mimalloc'
with:
rust-toolchain: stable
command: build
args: --release --out dist --features mimalloc --interpreter ${{ matrix.interpreter || env.PY_ALL }}
target: ${{ matrix.target }} target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }} manylinux: ${{ matrix.manylinux || 'auto' }}
container: ${{ matrix.container }} container: ${{ matrix.container }}

View file

@ -30,10 +30,10 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu, macos, windows] os: [ubuntu, macos]
target: [x86_64, aarch64] target: [x86_64, aarch64]
manylinux: [auto] manylinux: [auto]
allocator: [auto] allocator: [jemalloc]
include: include:
- os: ubuntu - os: ubuntu
platform: linux platform: linux
@ -48,6 +48,7 @@ jobs:
platform: linux platform: linux
target: i686 target: i686
interpreter: 3.9 3.10 3.11 3.12 3.13 3.14 interpreter: 3.9 3.10 3.11 3.12 3.13 3.14
allocator: jemalloc
- os: ubuntu - os: ubuntu
platform: linux platform: linux
target: aarch64 target: aarch64
@ -65,6 +66,7 @@ jobs:
platform: linux platform: linux
target: armv7 target: armv7
interpreter: 3.9 3.10 3.11 3.12 3.13 3.14 interpreter: 3.9 3.10 3.11 3.12 3.13 3.14
allocator: jemalloc
- os: ubuntu - os: ubuntu
platform: linux platform: linux
target: x86_64 target: x86_64
@ -96,14 +98,8 @@ jobs:
allocator: mimalloc allocator: mimalloc
- os: windows - os: windows
target: x86_64 target: x86_64
interpreter: 3.9 3.10 3.11 3.12 3.13 3.14 pypy3.9 pypy3.10 pypy3.11 interpreter: 3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11
- os: windows
target: x86_64
interpreter: 3.13t 3.14t
allocator: mimalloc allocator: mimalloc
exclude:
- os: windows
target: aarch64
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest
steps: steps:
@ -113,21 +109,10 @@ jobs:
run: | run: |
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
- uses: pyo3/maturin-action@v1 - uses: pyo3/maturin-action@v1
if: matrix.allocator != 'mimalloc'
with: with:
rust-toolchain: stable rust-toolchain: stable
command: build command: build
args: --release --out dist --interpreter ${{ matrix.interpreter || env.PY_ALL }} args: --release --out dist --features ${{ matrix.allocator }} --interpreter ${{ matrix.interpreter || env.PY_ALL }}
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
container: ${{ matrix.container }}
docker-options: -e CI
- uses: pyo3/maturin-action@v1
if: matrix.allocator == 'mimalloc'
with:
rust-toolchain: stable
command: build
args: --release --out dist --features mimalloc --interpreter ${{ matrix.interpreter || env.PY_ALL }}
target: ${{ matrix.target }} target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }} manylinux: ${{ matrix.manylinux || 'auto' }}
container: ${{ matrix.container }} container: ${{ matrix.container }}

View file

@ -11,20 +11,25 @@ on:
jobs: jobs:
linux: linux:
name: linux (${{ matrix.python-version }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
allocator: [jemalloc]
python-version: python-version:
- '3.9' - '3.9'
- '3.10' - '3.10'
- '3.11' - '3.11'
- '3.12' - '3.12'
- '3.13' - '3.13'
- '3.13t'
- '3.14' - '3.14'
- '3.14t'
- pypy3.11 - pypy3.11
include:
- python-version: 3.13t
allocator: mimalloc
- python-version: 3.14t
allocator: mimalloc
env: env:
UV_PYTHON: ${{ matrix.python-version }} UV_PYTHON: ${{ matrix.python-version }}
@ -38,26 +43,31 @@ jobs:
uv python install ${{ env.UV_PYTHON }} uv python install ${{ env.UV_PYTHON }}
uv venv .venv uv venv .venv
uv sync --group all uv sync --group all
uv run --no-sync maturin develop --uv uv run --no-sync maturin develop --uv --features ${{ matrix.allocator }}
- name: Test - name: Test
run: | run: |
source .venv/bin/activate source .venv/bin/activate
make test make test
macos: macos:
name: macos (${{ matrix.python-version }})
runs-on: macos-latest runs-on: macos-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
allocator: [jemalloc]
python-version: python-version:
- '3.9' - '3.9'
- '3.10' - '3.10'
- '3.11' - '3.11'
- '3.12' - '3.12'
- '3.13' - '3.13'
- '3.13t'
- '3.14' - '3.14'
- '3.14t' include:
- python-version: 3.13t
allocator: mimalloc
- python-version: 3.14t
allocator: mimalloc
env: env:
UV_PYTHON: ${{ matrix.python-version }} UV_PYTHON: ${{ matrix.python-version }}
@ -71,7 +81,7 @@ jobs:
uv python install ${{ env.UV_PYTHON }} uv python install ${{ env.UV_PYTHON }}
uv venv .venv uv venv .venv
uv sync --group all uv sync --group all
uv run --no-sync maturin develop --uv uv run --no-sync maturin develop --uv --features ${{ matrix.allocator }}
- name: Test - name: Test
run: | run: |
source .venv/bin/activate source .venv/bin/activate
@ -104,7 +114,7 @@ jobs:
uv python install ${{ env.UV_PYTHON }} uv python install ${{ env.UV_PYTHON }}
uv venv .venv uv venv .venv
uv sync --group all uv sync --group all
uv run --no-sync maturin develop --uv uv run --no-sync maturin develop --uv --features mimalloc
- name: Test - name: Test
run: | run: |
uv run --no-sync pytest -v tests uv run --no-sync pytest -v tests

View file

@ -50,19 +50,18 @@ pyo3 = { version = "=0.25", features = ["anyhow", "extension-module", "generate-
pyo3-log = "=0.12" pyo3-log = "=0.12"
rustls-pemfile = "2.2" rustls-pemfile = "2.2"
socket2 = { version = "=0.5.10", features = ["all"] } socket2 = { version = "=0.5.10", features = ["all"] }
tikv-jemallocator = { version = "0.6.0", default-features = false, features = ["disable_initial_exec_tls"], optional = true }
tls-listener = { version = "=0.11", features = ["rustls-ring"] } tls-listener = { version = "=0.11", features = ["rustls-ring"] }
tokio = { version = "1.45", features = ["full"] } tokio = { version = "1.45", features = ["full"] }
tokio-stream = "0.1" tokio-stream = "0.1"
tokio-tungstenite = "=0.26" tokio-tungstenite = "=0.26"
tokio-util = { version = "0.7", features = ["codec", "rt"] } tokio-util = { version = "0.7", features = ["codec", "rt"] }
[target.'cfg(not(any(target_env = "musl", target_os = "freebsd", target_os = "openbsd", target_os = "windows")))'.dependencies]
tikv-jemallocator = { version = "0.6.0", default-features = false, features = ["disable_initial_exec_tls"] }
[build-dependencies] [build-dependencies]
pyo3-build-config = "=0.25" pyo3-build-config = "=0.25"
[features] [features]
jemalloc = ["dep:tikv-jemallocator"]
mimalloc = ["dep:mimalloc"] mimalloc = ["dep:mimalloc"]
[profile.release] [profile.release]

View file

@ -1,14 +1,8 @@
#[cfg(not(any( #[cfg(all(feature = "jemalloc", not(feature = "mimalloc")))]
target_env = "musl",
target_os = "freebsd",
target_os = "openbsd",
target_os = "windows",
feature = "mimalloc"
)))]
#[global_allocator] #[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
#[cfg(feature = "mimalloc")] #[cfg(all(feature = "mimalloc", not(feature = "jemalloc")))]
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;