Conversation
rofi did all of its startup work serially before showing the window, so time-to-first-paint paid for every step up front. Two changes move the biggest filesystem/CPU-bound chunks off the critical path: - Initialize the icon fetcher lazily on the first icon query instead of eagerly in main(). Modes that show no icons (and the path to first paint) no longer pay to load icon themes, gdk-pixbuf loaders and thumbnailers. - Run the remaining X-independent startup work -- mode data loading (.desktop/$PATH/history scans) and the icon-theme setup -- on a background thread spawned right after the modes are configured, so it overlaps the latency-bound X server setup and the pango/font setup that follow. The worker is joined before the data is consumed (and as a safety net in cleanup(), before the modes are destroyed). Mode _init is only prefetched when verified safe: filesystem and its own private data only, no X and no state the main thread mutates concurrently (drun, run, ssh, filebrowser; they read the already-parsed rofi_configuration, not the still-resolving rofi_theme). Default-deny -- window calls xcb_ewmh_* in its _init, and combi initializes its (possibly X-using) sub-modes, so both stay serial. Measured with `rofi -show drun` over 800 entries (desktop cache off): first paint drops from ~74ms to ~42ms median (-43%); the win scales with the mode-load cost. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
futpib
marked this pull request as ready for review
May 29, 2026 23:58
This branch has not been deployed
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.
rofi did all of its startup work serially before showing the window, so time-to-first-paint paid for every step up front. Two changes move the biggest filesystem/CPU-bound chunks off the critical path:
Initialize the icon fetcher lazily on the first icon query instead of eagerly in main(). Modes that show no icons (and the path to first paint) no longer pay to load icon themes, gdk-pixbuf loaders and thumbnailers.
Run the remaining X-independent startup work -- mode data loading (.desktop/$PATH/history scans) and the icon-theme setup -- on a background thread spawned right after the modes are configured, so it overlaps the latency-bound X server setup and the pango/font setup that follow. The worker is joined before the data is consumed (and as a safety net in cleanup(), before the modes are destroyed).
Mode init is only prefetched when verified safe: filesystem and its own private data only, no X and no state the main thread mutates concurrently (drun, run, ssh, filebrowser; they read the already-parsed rofi_configuration, not the still-resolving rofi_theme). Default-deny -- window calls xcb_ewmh* in its _init, and combi initializes its (possibly X-using) sub-modes, so both stay serial.
Measured with
rofi -show drunover 800 entries (desktop cache off): first paint drops from ~74ms to ~42ms median (-43%); the win scales with the mode-load cost.