Repository navigation
Cut idle session memory by 12 MB - #10
Merged
Merged
Conversation
The minimize GIF is already gone and nothing else uses two-screens.webp, so the second row of the screenshot table goes with them.
Clippy's map_unwrap_or lint rejected the map().unwrap_or_else() chain, which broke cargo clippy --workspace -D warnings.
Starts the headless session, waits for it to settle (30 s by default) and prints PSS, RSS and thread count for every FlameWM process, split into binary, libraries, heap, stacks, fonts and shared memory, plus the total.
When a node already showed identical pixels, the document kept its old Arc and the caller kept the new one, so both copies stayed alive. The desktop decodes the wallpaper twice at startup (initial request, then the settings snapshot), which left two 8 MB root canvases resident on a dual 1280x800 layout. Swapping in the new Arc frees the old copy without bumping the image revision.
Whole-program LTO trims about 1.7 MB of resident code across the idle session (WM, desktop, shell, session) with opt-level 3 kept, so the drag and blur paths keep their codegen.
After startup the shell kept about 1.3 MB of freed heap that sat between live chunks, where the trim threshold never reaches it. Trim once, ten seconds after start, and again on the existing minute clock tick so later churn does not pile up either. No new wakeups beyond the one-shot timer.
Each base name used to be its own boxed string behind a hash table. The WM, desktop and shell each build this index, so keeping the names in one buffer and finding them by binary search saves roughly 0.2-0.4 MB of heap per process.
Same one-shot trim the shell does ten seconds after start. The WM keeps about 0.5 MB less freed heap from building the catalog and icon index, the desktop about 0.1 MB.
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.
Cuts idle memory of the X11 session from 51.3 MiB to 39.2 MiB total PSS (dual 1280x800 dummy outputs, 30 s idle), with no visible change. Also drops the minimize and two-screens rows from the README screenshot table.
The 10 MB goal is not reached. What is left is mostly resident code and shared libraries, plus the desktop's wallpaper copy. Getting further needs design trade-offs, listed below.
How it was measured
This PR adds the
idle-memorycommand. It starts the headless session, waits 30 s, then reads/proc/<pid>/smapsfor every FlameWM process. Each process gets PSS, RSS and thread count, split into binary, libs, heap, stacks, fonts and shm. Heap attribution came from heaptrack runs against a build with symbols.The three runs after the changes came in at 39.15, 39.33 and 39.19 MiB.
Changes
map_unwrap_orin the shell icon cache.Checks
cargo fmt --check: passcargo clippy --workspace -- -D warnings: passcargo test --workspace --no-fail-fast: everything passes except two tests that also fail onmain:xrender_aa::clipped_arc_tests::clipped_runs_preserve_partial_corner_coveragefails onmaintoo.flamewm-remote-fslist_cache_serves_within_ttl_and_invalidates_on_mutationis timing-flaky, 1 in 5 locally. That crate is not touched here.tools/flamewm_visual_tests.py --layout both: all checks pass.What is left (not applied, each needs a trade-off)
opt-level = "s"workspace-widedlopen/unsafe FFI, which means a new architecture exception.Everything else I looked at came in under 200 KB, which is below the run-to-run noise on resident code pages (about ±200 KB). Memory figures in the README and
docs/PERFORMANCE.mdare unchanged because the 10 MB target was not met.