Repository navigation
perf(gui): skip Vulkan drivers for absent GPU vendors - #248
Conversation
An AMD-only box with nvidia-utils spent 0.6 to 1.1 s in vkCreateInstance on the NVIDIA ICD, once in the probe and again in Qt. The launcher now disables known-vendor manifests no PCI display controller or card matches, marked with the exact filter so opened programs drop only Flea's own.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe launcher now identifies Vulkan ICD manifests for GPU vendors absent from the machine and applies a marked driver filter before renderer probing. It preserves operator-selected settings and removes Flea-owned filters from child launchers. The change also adds JSON parsing, tests, and documentation. ChangesVulkan ICD filtering
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant GUI as qs_command
participant Exclusion as exclude_absent_vendors
participant Hardware as PCI and DRM inventory
participant Manifests as ICD manifest inventory
participant Loader as Vulkan loader environment
GUI->>Exclusion: invoke before renderer probing
Exclusion->>Hardware: identify display-device vendors
Exclusion->>Manifests: inspect ICD manifests
Manifests-->>Exclusion: return recognized vendor libraries
Hardware-->>Exclusion: return detected vendor IDs
Exclusion->>Loader: set absent-vendor filter and ownership marker
Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue was found in the reviewed change. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change affects which installed GPU drivers are loaded and how that setting reaches child programs. Filtering is bounded and normally defers to explicit driver choices. No concrete security regression was established, but deployment-specific environment trust and loader compatibility remain unverified. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 40.82% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 49 functions across 9 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Re-measured in a lab guest updated to Omarchy 4.0.4: the NVIDIA ICD costs the launch about 20 ms there, 17 to 31 ms against 2.9 to 6.2 ms. The reproducing box carries a Granite Ridge iGPU, not a Raphael one.
The 12 VM launches to a stub qs were interleaved pairs. The decision cost, re-measured over 25 pairs against the same build given the operator's own filter, is a paired median of 0.06 ms on the AMD box and in the guest, not about 0.3 ms.
|
Nice! Thank you, will include in 0.3.9 |
|
merged as authored; Vulkan drivers for GPU vendors the box lacks are skipped before the probe (ae786aa, v0.3.10). Thanks @t1nk333r! https://github.com/thisisgm/flea/releases/tag/v0.3.10 |
Problem
On a box that has a GPU vendor's Vulkan driver installed without that vendor's GPU, Flea initialises that driver twice on every launch: once in the launcher's Vulkan probe (
vulkan::usable()) and again when Qt creates its Vulkan instance inqs.Reproduced on an AMD-only box (RX 7900 XTX beside a Granite Ridge iGPU) with
nvidia-utils610.57.04 installed:vkCreateInstancewith every ICD: 0.63 to 1.1 s, and it finds no NVIDIA device. Almost all of it is the NVIDIA ICD runningnvidia-modprobetwice, 365 to 370 ms each on that box.VK_LOADER_DRIVERS_DISABLE=nvidia_icd.json: 6 to 8 ms, same two AMD devices.The display-GPU pin does not apply here, because every device the probe lists is AMD.
Change
src/icdexclude.rsruns once inqs_command, before the probe and beforeqs, in every renderer arm (the OpenGL retry inherits the shell's environment, and zink draws GL through Vulkan). It setsVK_LOADER_DRIVERS_DISABLEto the manifest file names whoseICD.library_pathfile name is exactly one of six packaged hardware driver libraries (libGLX_nvidia.so.0,libvulkan_nouveau.so,libvulkan_radeon.so,amdvlk64.so,amdvlk32.so,libvulkan_intel.so) and whose vendor no PCI display controller (class 0x03) and no PCI-backed DRM card carries. The loader skips those manifests before it loads their libraries.It is conservative by construction and excludes nothing when:
VK_DRIVER_FILES,VK_ICD_FILENAMES,VK_ADD_DRIVER_FILES,VK_LOADER_DRIVERS_SELECTorVK_LOADER_DRIVERS_DISABLE, or a loader settings file (vulkan/loader_settings.d/vk_loader_settings.json) exists;Vendor presence comes from
/sys/bus/pci/devicesand/sys/class/drm, never from Vulkan, so a dGPU withoutnvidia-drmloaded keeps its driver. Any other library is kept, whatever vendor its name mentions (lavapipe, hasvk, swiftshader, Venus, whose vtest transport needs no virtio device, and wrappers), as are malformed or oversized manifests. Because the loader's filter names files rather than paths and compares case-insensitively, a file name is excluded only when every manifest carrying it on a superset of the loader's search path names an absent vendor; only literal names are written, NVIDIA's first, at most 16 (the loader's limit).FLEA_VK_DISABLEholds the exact filter Flea wrote. A new window or the OpenGL retry decides again;flea --openandflea --terminalremove Flea's own filter from the program they start, like the existing pin; a filter that differs from the marker is the operator's and is kept.vulkan::icd_librarynow readsICD.library_paththroughjsondoc(shared with the pin) and the newsrc/jsonmembers.rs, which finds both keys as the loader's cJSON does (any case, names compared up to a NUL as C strings) and sees exact repeats thatjsondoc::parsefolds. A repeat of either key, or a path holding a NUL, names no library; metadata elsewhere in a manifest changes nothing, so the pin keeps working for such manifests.Results
vkCreateInstancein the probeqs(12 interleaved pairs)The AMD-box rows were measured on the first revision of this branch; later revisions only narrow which unusual manifests may be excluded and leave that box's decision (
nvidia_icd.json) unchanged, which the final revision's stub-qshandoff confirms. The VM row is the final revision, in a lab guest installed as Omarchy 4.0.2 and updated withomarchy updateto 4.0.4 (Hyprland 0.56.2, Qt 6.11.2, Vulkan loader 1.4.357), because the 4.0.4 ISO's offline install stops on missing kernel headers. The window still runs on Vulkan on the AMD box, andlibGLX_nvidiais not mapped inqs. In the VMnvidia-modprobereturns in 2 ms, so the gain there is about 20 ms (medians 24.9 against 4.2 ms; the two arms never overlap): the size of the win depends on how slow that helper is on the box. The VM has no Vulkan device, so both builds open the window on OpenGL and paint the listing; real windows there only show that, not the 20 ms, which the window's own startup noise hides. Withoutnvidia-utilsboth builds handqsthe same environment and set no filter. Deciding costs well under a millisecond: over 25 interleaved pairs of launches to a stubqs, the same build given the operator's own filter, which skips the decision, differs by a paired median of 0.06 ms on the AMD box (deciding slower in 14 of 25 pairs, inside the noise) and in the VM (19 of 25). A loader older than 1.3.234 ignores the variable and behaves as before. Nothing is printed, because no device changes.Tests
src/icdexclude_tests.rs: absent and present vendors, 3D controllers without a DRM card, non-PCI cards, shared and case-variant names, symlinks, FIFOs, oversized and ambiguous manifests, glob characters, the 16 and 256 limits, non-UTF-8 search roots, marker ownership and operator variables. Each rule was mutated and a test fails.src/vulkan.rsandsrc/jsonmembers.rs: case-insensitive member lookup, refusal of repeated keys (including escaped spellings), and a pin fixture whose manifest carries metadata mentioninglibrary_path.tests/modes.sh: the marker equals the filter, an inherited filter is decided again (automatic and OpenGL), a leaked marker leaves the operator's filter alone, a settings file and an explicit driver list exclude nothing, and--open/--terminaldrop only Flea's own filter.cargo test --locked: 1156 passed.tools/flea-clippy: pass, nothing rose.tools/flea-file-budget: pass.tests/modes.sh: 262 ok.tests/run-all.sh: the 7 suites that fail here fail identically onmainon this box (stale charts, missing media fixture,media.shhelper,pdf-turn,gridhidden,protocolthumbnails).nvidia-utils:tests/modes.sh257 ok on this branch and 232 onmain, with the same 6 failures on both, the checks that expect a Vulkan device the VM does not have.Known limits
gio launch) inherit the filter, as they already inherit the display-GPU pin. It names only drivers for absent vendors, so the visible effect is limited to an eGPU of such a vendor plugged in while Flea runs.libEGL_nvidia) in both builds; EGL vendor selection is left alone.Summary by CodeRabbit