From 8708ae0e37084d44dfc2d89e5d14731382f82236 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 19 Aug 2023 07:53:39 +0100 Subject: [PATCH] bash: disable `bash-malloc` everywhere, not just on `musl` TIme to time I bump into pathological behaviour of `bash` memory allocator. Today's example: $ time { ls /nix/store/ > /dev/null; } real 0m0,965s user 0m0,876s sys 0m0,087s $ time { echo /nix/store/* > /dev/null; } real 2m18,287s user 2m17,946s sys 0m0,125s $ time { echo /nix/store/* > /dev/null; } real 0m1,764s user 0m1,712s sys 0m0,048s Note how initial `echo` takes alsmot 2 minutes to finish. Let's rely on system's allocator instead. After the change initial run is fast again: $ time { echo /nix/store/* > /dev/null; } real 0m1,328s user 0m1,264s sys 0m0,063s --- pkgs/shells/bash/5.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/shells/bash/5.nix b/pkgs/shells/bash/5.nix index 00b4a707ed08..7e815751ef72 100644 --- a/pkgs/shells/bash/5.nix +++ b/pkgs/shells/bash/5.nix @@ -64,6 +64,12 @@ stdenv.mkDerivation rec { ]; configureFlags = [ + # At least on Linux bash memory allocator has pathological performance + # in scenarios involving use of larger memory: + # https://lists.gnu.org/archive/html/bug-bash/2023-08/msg00052.html + # Various distributions default to system allocator. Let's nixpkgs + # do the same. + "--without-bash-malloc" (if interactive then "--with-installed-readline" else "--disable-readline") ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "bash_cv_job_control_missing=nomissing" @@ -77,7 +83,6 @@ stdenv.mkDerivation rec { "bash_cv_dev_fd=standard" "bash_cv_termcap_lib=libncurses" ] ++ lib.optionals (stdenv.hostPlatform.libc == "musl") [ - "--without-bash-malloc" "--disable-nls" ];