Repository navigation
Conversation
With Arch's transparent huge pages always on, jemalloc backed the shell's arenas with 2 MB pages it mostly never touched, and its default of four arenas per CPU gave each of the shell's threads its own pool of freed pages. It also only returns freed pages while the program keeps allocating, which an idle shell does not. thp:never, one arena and the background purge thread take about 150 MB off an idle shell and let memory freed later actually leave. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
This was referenced Oct 12, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Programs the shell starts inherit MALLOC_CONF, and one arena halved the speed of a multithreaded jemalloc program like fd. The arena count now comes compiled into Omarchy's quickshell package; huge pages off and the background purge thread stay here, since they cost a child nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
omarchy-launch-shellstarts Quickshell withMALLOC_CONF=thp:never,background_thread:true. AMALLOC_CONFthe user already set is appended after it, so their options still win (jemalloc applies options in order).The single arena (
narenas:1), the other big win, is compiled into Omarchy's quickshell package instead: omacom/omarchy-pkgs#1004. It can't go in the environment, because programs the shell starts inheritMALLOC_CONF.Why
I profiled the shell before changing anything. Quickshell allocates through jemalloc, and on a stock Omarchy machine the allocator's defaults were the biggest single cost in the process, ahead of anything the QML does:
transparent_hugepage=always. jemalloc's arenas got backed by 2 MB pages that are mostly never touched. On an idle shell, 230–270 MB of the ~330 MB anonymous memory sat inAnonHugePages.Apps started from the launcher, menu or bar go through
execDetached, thenuwsm-app, then a scope, and they inherit the shell's environment. So does everything run in a terminal opened that way. An earlier revision of this PR putnarenas:1there too, and a review caught the effect on children. I measuredfd -u . /usr(best of 5):thp:never,background_thread:true(this PR)thp:never,narenas:1,background_thread:trueThe two options kept here cost a child nothing.
background_threadadds one sleeping thread to a jemalloc process; I counted 2 threads instead of 1 in a jemalloc-preloaded Python. Keyboard-launched terminals don't go through the shell and get neither option.Measurements
One monitor, 2560x1440 at scale 1.6, Starship theme, the user's real 16-widget bar. Numbers are from
/proc/<pid>/smaps_rollup, RSS in MB.Frame timing with
QSG_RENDER_TIMING=1, across the open/close sequence of every panel (about 680 frames per run, two runs each), comparing stock quickshell with the patched one:One arena doesn't change frame times measurably.
Tests
test/shell.d/launch-shell-test.shasks jemalloc itself, throughmallctl, which options it parsed from the environment the shell got: huge pages off, the background thread on, and the arena count left at jemalloc's own default. It also checks that a user'sMALLOC_CONFoverrides ours. Mutation-checked: addingnarenas:1back, or dropping the variable, fails it../test/shell: only the 6 known baseline failures../test/clipasses.displayCutoutsandhintsones.For a human to check
grep -E 'Rss|AnonHuge' /proc/$(pgrep -f 'quickshell -n -p')/smaps_rollup. Expect about 400 MB RSS without the package change and about 320 MB with it.🤖 Generated with Claude Code