Skip to content

perf(gui): skip Vulkan drivers for absent GPU vendors - #248

Merged
thisisgm merged 3 commits into
thisisgm:mainfrom
t1nk333r:vulkan-skip-absent-vendor-icds
Oct 13, 2026
Merged

thisisgm merged 3 commits into
thisisgm:mainfrom
t1nk333r:vulkan-skip-absent-vendor-icds

Conversation

@t1nk333r

@t1nk333r t1nk333r commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

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 in qs.

Reproduced on an AMD-only box (RX 7900 XTX beside a Granite Ridge iGPU) with nvidia-utils 610.57.04 installed:

  • vkCreateInstance with every ICD: 0.63 to 1.1 s, and it finds no NVIDIA device. Almost all of it is the NVIDIA ICD running nvidia-modprobe twice, 365 to 370 ms each on that box.
  • The same call with VK_LOADER_DRIVERS_DISABLE=nvidia_icd.json: 6 to 8 ms, same two AMD devices.
  • Super+Shift+F mapped the window 1.56 to 1.62 s after the key.

The display-GPU pin does not apply here, because every device the probe lists is AMD.

Change

src/icdexclude.rs runs once in qs_command, before the probe and before qs, in every renderer arm (the OpenGL retry inherits the shell's environment, and zink draws GL through Vulkan). It sets VK_LOADER_DRIVERS_DISABLE to the manifest file names whose ICD.library_path file 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:

  • the operator set VK_DRIVER_FILES, VK_ICD_FILENAMES, VK_ADD_DRIVER_FILES, VK_LOADER_DRIVERS_SELECT or VK_LOADER_DRIVERS_DISABLE, or a loader settings file (vulkan/loader_settings.d/vk_loader_settings.json) exists;
  • a display controller's vendor cannot be read, a DRM card sits off the PCI bus (SoC, virtio-mmio, evdi), or no display controller is found;
  • the search lists more than 256 manifests.

Vendor presence comes from /sys/bus/pci/devices and /sys/class/drm, never from Vulkan, so a dGPU without nvidia-drm loaded 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_DISABLE holds the exact filter Flea wrote. A new window or the OpenGL retry decides again; flea --open and flea --terminal remove 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_library now reads ICD.library_path through jsondoc (shared with the pin) and the new src/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 that jsondoc::parse folds. 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

upstream this branch
AMD box, window mapped (warm) 1622 to 1950 ms 154 to 185 ms
AMD box, vkCreateInstance in the probe 0.63 to 1.1 s 6 to 8 ms
Omarchy 4.0.4 VM + nvidia-utils, launcher to stub qs (12 interleaved pairs) 17 to 31 ms 2.9 to 6.2 ms

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-qs handoff confirms. The VM row is the final revision, in a lab guest installed as Omarchy 4.0.2 and updated with omarchy update to 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, and libGLX_nvidia is not mapped in qs. In the VM nvidia-modprobe returns 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. Without nvidia-utils both builds hand qs the same environment and set no filter. Deciding costs well under a millisecond: over 25 interleaved pairs of launches to a stub qs, 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.rs and src/jsonmembers.rs: case-insensitive member lookup, refusal of repeated keys (including escaped spellings), and a pin fixture whose manifest carries metadata mentioning library_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/--terminal drop 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 on main on this box (stale charts, missing media fixture, media.sh helper, pdf-turn, gridhidden, protocol thumbnails).
  • In the Omarchy 4.0.4 VM with nvidia-utils: tests/modes.sh 257 ok on this branch and 232 on main, with the same 6 failures on both, the checks that expect a Vulkan device the VM does not have.

Known limits

  • Helpers QML starts directly and Open With (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.
  • A FIFO placed in a manifest directory still blocks the loader's own probe, as before this change; Flea's own read no longer blocks on it.
  • The display pin keeps its own three-directory search; unifying the two directory lists is left for a follow-up.
  • No hybrid-GPU box was available. Hybrid shapes are covered by sysfs fixtures, and the pin's logic is unchanged apart from the stricter manifest reader.
  • This is the Vulkan loader only. Where Flea falls back to OpenGL, as in the VM, glvnd still loads NVIDIA's EGL library (libEGL_nvidia) in both builds; EGL vendor selection is left alone.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Vulkan renderer selection by excluding drivers for GPU vendors not present on the system when it’s safe to do so.
    • Preserved manually configured driver choices and loader settings; incomplete hardware or driver information won’t trigger exclusions.
    • Flea-specific exclusions are removed when launching other applications, without affecting unrelated settings.
    • Added safeguards so only Flea-managed exclusions are removed, preserving operator-provided filters even when a Flea marker is stale.

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.
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d51102e4-952a-443d-befb-42024d4615c2
📥 Commits

Reviewing files that changed from the base of the PR and between 5fa1685 and ae786aa.

📒 Files selected for processing (1)
  • AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • AGENTS.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Vulkan ICD filtering

Layer / File(s) Summary
Parse Vulkan ICD manifests
src/jsonmembers.rs, src/vulkan.rs, src/main.rs
A JSON member scanner returns a value only for a unique matching top-level member. Vulkan manifest parsing uses it to read an unambiguous ICD.library_path and reject invalid or ambiguous input. The modules are declared in src/main.rs.
Identify and filter absent vendors
src/icdexclude.rs, src/icdexclude_tests.rs
The exclusion code checks display-device vendors and ICD manifests, then selects safe absent-vendor manifest names within loader limits. Tests cover inventory, parsing, duplicate names, filename safety, loader settings, and limits.
Wire filtering into launch paths
src/gui.rs, src/open.rs, src/terminal.rs, tests/modes.sh, AGENTS.md, tools/flea-file-budget
GUI launches apply the filter before renderer probing. Open and terminal launchers remove a matching Flea-owned filter. Mode tests, module documentation, and file-budget records are updated.

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
Loading

Merge Risk: ⚪ Minimal · up to ae786

No actionable merge-blocking issue was found in the reviewed change.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 3859b

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is driver loading within the launcher's process lineage. Exclusions operate by manifest basename across inventoried loader directories, rather than by individual file path. Namesake validation limits that breadth, and cleanup prevents the optimization from propagating through the inspected open and detached-launch handoffs.

Security Findings and Attack Paths

  • inferred — A supplied matching marker/filter pair causes filter removal before operator-choice checks. This establishes an unauthenticated ownership convention, but not an independently exploitable security boundary: the same supplied environment already carries driver-selection controls, and lower-trust marker injection was not demonstrated. This condition is not retained as an active PR security concern.

Trust Boundaries and Controls

  • observed — Environment-provided search roots and filesystem manifests influence exclusions, but the new policy writes a disable list, not an attacker-library selection. Unknown or ambiguous namesakes prevent exclusion; incomplete required hardware data and non-PCI DRM cards stop filtering.

Resilience and Maintainability Implications

  • observed — Manifest discovery stops beyond 256 JSON entries, exclusion output stops at 16 names, and classification reads only the configured byte limit plus one byte through a regular-file helper. These controls bound manifest-driven work and avoid interpreting malformed inputs as authorization to suppress a driver.

Hardening Proposals

  • proposed — Document FLEA_VK_DISABLE as reserved launch-state metadata, not authenticated provenance. If a privileged or sandboxed launcher is introduced, establish environment sanitization at that boundary rather than treating marker equality as proof of trusted ownership.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: skipping Vulkan drivers for GPU vendors that are absent.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
@thisisgm

thisisgm commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Nice! Thank you, will include in 0.3.9

@thisisgm
thisisgm merged commit f196199 into thisisgm:main Oct 13, 2026
1 check passed
@thisisgm

Copy link
Copy Markdown
Owner

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

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.

2 participants