Skip to content

Optimize cold start and lazy-load offscreen QML - #216

Merged
dhh merged 2 commits into
mainfrom
optimize-cold-start
Nov 23, 2026
Merged

dhh merged 2 commits into
mainfrom
optimize-cold-start

Conversation

@dhh

@dhh dhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Cuts cold-start latency across folio, folio preview, and folio chooser by avoiding redundant startup work and deferring QML compilation/instantiation for offscreen dialogs, menus, overlays, and inactive folder views.

Changes

  • Theme (src/theme.h, src/theme.cpp): Reuse Qt's already-loaded FcConfigGetCurrent() on startup instead of calling FcInitLoadConfigAndFonts(), keeping fresh fontconfig reloads for live font changes. Precompute derived WCAG/theme colors (folderFill, tooltipBackground, tooltipForeground, lighterBackground, accentForeground, secondaryForeground) once per palette load instead of running luminance and contrast bisection on every QML read.
  • Lazy QML loading (src/Main.qml, src/PreviewWindow.qml, src/FolderPane.qml, src/FolderColumns.qml, src/Sidebar.qml, src/PathBar.qml, src/Glyph.qml): Load HelpOverlay, FileMenu, PlaceMenu, DriveMenu, SortMenu, all five pane dialogs (MountPrompt, RenameDialog, ConfirmDialog, FormatDialog, ClashDialog), PreviewPane, and inactive folder views (FolderGrid/FolderList/FolderColumns) via Loader by relative URL so they are neither compiled nor instantiated at startup. Load rare plugin SVG Images lazily in Glyph.
  • Translator (src/translator.h, src/translator.cpp): Key translations by UTF-8 QByteArray and look up with QByteArray::fromRawData() to avoid heap-allocating a QString on every tr()/qsTr() call; skip opening locales.json when OMARCHY_PATH is unset.
  • Places (src/places.cpp): Skip statvfs() (isReady()/bytesAvailable()) on pseudo, loop, zram, and system mounts in Places::readMounts(), and fetch g_volume_monitor_get_mounts() once per mountsRead() instead of once per drive.

Benchmarks

Measured offscreen on Release builds:

Benchmark Before After Speedup
Theme::followSystemFont() 25.91 ms 4.26 ms 6.1×
Windows() (compile Main + FolderPane) 82.99 ms 59.04 ms 1.4×
Windows::open(home) 138.57 ms 21.43 ms 6.5×
PreviewWindow cold load 82.96 ms 20.41 ms 4.1×
1000× Theme derived colors 21.03 ms < 0.01 ms > 2000×

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The changes since the previous review appear safe to merge.

Summary

This PR reduces startup work by loading hidden QML only when needed, caching theme colors, and reducing repeated font, translation, and mount work.

  • Folder panes load only the views and details they use.
  • Menus and dialogs are built when someone asks for them.
  • Help panels and plugin SVGs wait until they are needed.
  • Font setup and theme colors reuse work already done.
  • Translation lookups reuse UTF-8 keys instead of building QString keys.
  • Drive refresh skips virtual mounts and checks GIO mounts once.

Reviews (2) · Last reviewed commit: "Share sort order definitions between Pat..." · Reviewed by Greptile

Comment thread src/PathBar.qml Resolved
@dhh
dhh merged commit 17247b9 into main Nov 23, 2026
2 checks passed
@dhh
dhh deleted the optimize-cold-start branch November 23, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant