redis: use system jemalloc (#243398)

* redis: use system jemalloc
This commit is contained in:
Yureka 2023-07-15 20:02:13 +02:00 committed by GitHub
parent 42066dc04d
commit e16a75d3be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -441,6 +441,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- `pkgs.haskell-language-server` will now by default be linked dynamically to improve TemplateHaskell compatibility. To mitigate the increased closure size it will now by default only support our current default ghc (at the moment 9.0.2). Add other ghc versions via e.g. `pkgs.haskell-language-server.override { supportedGhcVersions = [ "90" "92" ]; }`.
- `pkgs.redis` is now built using the system jemalloc. This disables the experimental active defragmentation feature of redis. Users who require this feature can switch back to redis' vendored version of jemalloc by setting `services.redis.package = pkgs.redis.override { useSystemJemalloc = false; };`.
## Other Notable Changes {#sec-release-21.11-notable-changes}

View file

@ -1,8 +1,13 @@
{ lib, stdenv, fetchurl, fetchpatch, lua, pkg-config, nixosTests
{ lib, stdenv, fetchurl, fetchpatch, lua, jemalloc, pkg-config, nixosTests
, tcl, which, ps, getconf
, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
# dependency ordering is broken at the moment when building with openssl
, tlsSupport ? !stdenv.hostPlatform.isStatic, openssl
# Using system jemalloc fixes cross-compilation and various setups.
# However the experimental 'active defragmentation' feature of redis requires
# their custom patched version of jemalloc.
, useSystemJemalloc ? true
}:
stdenv.mkDerivation rec {
@ -20,19 +25,23 @@ stdenv.mkDerivation rec {
url = "https://github.com/redis/redis/commit/bfe50a30edff6837897964ac3374c082b0d9e5da.patch";
sha256 = "sha256-0GMiygbO7LbL1rnuOByOJYE2BKUSI+yy6YH781E2zBw=";
})
];
] ++ lib.optional useSystemJemalloc
# use system jemalloc
(fetchurl {
url = "https://gitlab.archlinux.org/archlinux/packaging/packages/redis/-/raw/102cc861713c796756abd541bf341a4512eb06e6/redis-5.0-use-system-jemalloc.patch";
hash = "sha256-VPRfoSnctkkkzLrXEWQX3Lh5HmZaCXoJafyOG007KzM=";
})
;
nativeBuildInputs = [ pkg-config ];
buildInputs = [ lua ]
++ lib.optional useSystemJemalloc jemalloc
++ lib.optional withSystemd systemd
++ lib.optionals tlsSupport [ openssl ];
# More cross-compiling fixes.
# Note: this enables libc malloc as a temporary fix for cross-compiling.
# Due to hardcoded configure flags in jemalloc, we can't cross-compile vendored jemalloc properly, and so we're forced to use libc allocator.
# It's weird that the build isn't failing because of failure to compile dependencies, it's from failure to link them!
makeFlags = [ "PREFIX=${placeholder "out"}" ]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "AR=${stdenv.cc.targetPrefix}ar" "RANLIB=${stdenv.cc.targetPrefix}ranlib" "MALLOC=libc" ]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "AR=${stdenv.cc.targetPrefix}ar" "RANLIB=${stdenv.cc.targetPrefix}ranlib" ]
++ lib.optionals withSystemd [ "USE_SYSTEMD=yes" ]
++ lib.optionals tlsSupport [ "BUILD_TLS=yes" ];