Loading pkgs/development/python-modules/granian/default.nix +8 −18 Original line number Diff line number Diff line { lib, stdenv, fetchFromGitHub, rustPlatform, cacert, Loading @@ -14,7 +13,6 @@ pytest-asyncio, websockets, httpx, rust-jemalloc-sys, sniffio, nix-update-script, }: Loading @@ -31,6 +29,14 @@ buildPythonPackage rec { hash = "sha256-qJ65ILj7xLqOWmpn1UzNQHUnzFg714gntVSmYHpI65I="; }; # Granian forces a custom allocator for all the things it runs, # which breaks some libraries in funny ways. Make it not do that, # and allow the final application to make the allocator decision # via LD_PRELOAD or similar. patches = [ ./no-alloc.patch ]; cargoDeps = rustPlatform.fetchCargoVendor { inherit pname version src; hash = "sha256-swfqKp8AsxNAUc7dlce6J4dNQbNGWrCcUDc31AhuMmI="; Loading @@ -41,22 +47,6 @@ buildPythonPackage rec { maturinBuildHook ]; buildInputs = lib.optionals (stdenv.hostPlatform.isAarch64) [ # fix "Unsupported system page size" on aarch64-linux with 16k pages # https://github.com/NixOS/nixpkgs/issues/410572 # only enabled on aarch64 due to https://github.com/NixOS/nixpkgs/pull/410611#issuecomment-2939564567 (rust-jemalloc-sys.overrideAttrs ( { configureFlags, ... }: { configureFlags = configureFlags ++ [ # otherwise import check fails with: # ImportError: {{storeDir}}/lib/libjemalloc.so.2: cannot allocate memory in static TLS block "--disable-initial-exec-tls" ]; } )) ]; dependencies = [ click ]; Loading pkgs/development/python-modules/granian/no-alloc.patch 0 → 100644 +50 −0 Original line number Diff line number Diff line diff --git a/Cargo.toml b/Cargo.toml index 4e6676f..1657d61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,6 @@ hyper = { version = "=1.6", features = ["http1", "http2", "server"] } hyper-util = { version = "=0.1", features = ["server-auto", "tokio"] } itertools = "0.14" log = "0.4" -mimalloc = { version = "0.1.43", default-features = false, features = ["local_dynamic_tls"], optional = true } mime_guess = "=2.0" pem = "=3.0" percent-encoding = "=2.3" @@ -56,15 +55,9 @@ tokio-stream = "0.1" tokio-tungstenite = "=0.26" 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] pyo3-build-config = "=0.25" -[features] -mimalloc = ["dep:mimalloc"] - [profile.release] codegen-units = 1 debug = false diff --git a/src/lib.rs b/src/lib.rs index 9172842..6c41005 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,17 +1,3 @@ -#[cfg(not(any( - target_env = "musl", - target_os = "freebsd", - target_os = "openbsd", - target_os = "windows", - feature = "mimalloc" -)))] -#[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; - -#[cfg(feature = "mimalloc")] -#[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; - use pyo3::prelude::*; use std::sync::OnceLock; Loading
pkgs/development/python-modules/granian/default.nix +8 −18 Original line number Diff line number Diff line { lib, stdenv, fetchFromGitHub, rustPlatform, cacert, Loading @@ -14,7 +13,6 @@ pytest-asyncio, websockets, httpx, rust-jemalloc-sys, sniffio, nix-update-script, }: Loading @@ -31,6 +29,14 @@ buildPythonPackage rec { hash = "sha256-qJ65ILj7xLqOWmpn1UzNQHUnzFg714gntVSmYHpI65I="; }; # Granian forces a custom allocator for all the things it runs, # which breaks some libraries in funny ways. Make it not do that, # and allow the final application to make the allocator decision # via LD_PRELOAD or similar. patches = [ ./no-alloc.patch ]; cargoDeps = rustPlatform.fetchCargoVendor { inherit pname version src; hash = "sha256-swfqKp8AsxNAUc7dlce6J4dNQbNGWrCcUDc31AhuMmI="; Loading @@ -41,22 +47,6 @@ buildPythonPackage rec { maturinBuildHook ]; buildInputs = lib.optionals (stdenv.hostPlatform.isAarch64) [ # fix "Unsupported system page size" on aarch64-linux with 16k pages # https://github.com/NixOS/nixpkgs/issues/410572 # only enabled on aarch64 due to https://github.com/NixOS/nixpkgs/pull/410611#issuecomment-2939564567 (rust-jemalloc-sys.overrideAttrs ( { configureFlags, ... }: { configureFlags = configureFlags ++ [ # otherwise import check fails with: # ImportError: {{storeDir}}/lib/libjemalloc.so.2: cannot allocate memory in static TLS block "--disable-initial-exec-tls" ]; } )) ]; dependencies = [ click ]; Loading
pkgs/development/python-modules/granian/no-alloc.patch 0 → 100644 +50 −0 Original line number Diff line number Diff line diff --git a/Cargo.toml b/Cargo.toml index 4e6676f..1657d61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,6 @@ hyper = { version = "=1.6", features = ["http1", "http2", "server"] } hyper-util = { version = "=0.1", features = ["server-auto", "tokio"] } itertools = "0.14" log = "0.4" -mimalloc = { version = "0.1.43", default-features = false, features = ["local_dynamic_tls"], optional = true } mime_guess = "=2.0" pem = "=3.0" percent-encoding = "=2.3" @@ -56,15 +55,9 @@ tokio-stream = "0.1" tokio-tungstenite = "=0.26" 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] pyo3-build-config = "=0.25" -[features] -mimalloc = ["dep:mimalloc"] - [profile.release] codegen-units = 1 debug = false diff --git a/src/lib.rs b/src/lib.rs index 9172842..6c41005 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,17 +1,3 @@ -#[cfg(not(any( - target_env = "musl", - target_os = "freebsd", - target_os = "openbsd", - target_os = "windows", - feature = "mimalloc" -)))] -#[global_allocator] -static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; - -#[cfg(feature = "mimalloc")] -#[global_allocator] -static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; - use pyo3::prelude::*; use std::sync::OnceLock;