build: link jemalloc by default to reduce heap fragmentation

The QML engine and the quickshell reloader both cause large amounts of
heap fragmentation that stacks up over time, leading to a perceived
memory leak. Jemalloc is able to handle the fragmentation much better,
leading to lower user facing memory usage.
This commit is contained in:
outfoxxed 2024-05-31 01:28:35 -07:00
parent d56c07ceb3
commit a8506edbb9
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 24 additions and 7 deletions

View file

@ -8,6 +8,7 @@
cmake,
ninja,
qt6,
jemalloc,
wayland,
wayland-protocols,
xorg,
@ -29,7 +30,8 @@
enableX11 ? true,
enablePipewire ? true,
nvidiaCompat ? false,
svgSupport ? true, # you almost always want this
withQtSvg ? true, # svg support
withJemalloc ? true, # masks heap fragmentation
}: buildStdenv.mkDerivation {
pname = "quickshell${lib.optionalString debug "-debug"}";
version = "0.1.0";
@ -39,8 +41,8 @@
cmake
ninja
qt6.wrapQtAppsHook
] ++ (lib.optionals enableWayland [
pkg-config
] ++ (lib.optionals enableWayland [
wayland-protocols
wayland-scanner
]);
@ -49,10 +51,11 @@
qt6.qtbase
qt6.qtdeclarative
]
++ (lib.optional withJemalloc jemalloc)
++ (lib.optional withQtSvg qt6.qtsvg)
++ (lib.optionals enableWayland [ qt6.qtwayland wayland ])
++ (lib.optionals enableX11 [ xorg.libxcb ])
++ (lib.optionals svgSupport [ qt6.qtsvg ])
++ (lib.optionals enablePipewire [ pipewire ]);
++ (lib.optional enableX11 xorg.libxcb)
++ (lib.optional enablePipewire pipewire);
QTWAYLANDSCANNER = lib.optionalString enableWayland "${qt6.qtwayland}/libexec/qtwaylandscanner";
@ -67,7 +70,9 @@
cmakeFlags = [
"-DGIT_REVISION=${gitRev}"
] ++ lib.optional (!enableWayland) "-DWAYLAND=OFF"
]
++ lib.optional (!withJemalloc) "-DUSE_JEMALLOC=OFF"
++ lib.optional (!enableWayland) "-DWAYLAND=OFF"
++ lib.optional nvidiaCompat "-DNVIDIA_COMPAT=ON"
++ lib.optional (!enablePipewire) "-DSERVICE_PIPEWIRE=OFF";