fix: stop watching parent directories in DesktopEntryMonitor - #930
Open
short-circuit wants to merge 1 commit into
Open
fix: stop watching parent directories in DesktopEntryMonitor#930short-circuit wants to merge 1 commit into
short-circuit wants to merge 1 commit into
Conversation
addPathAndParents was adding QFileSystemWatcher watches on every parent directory of each desktop entry path, all the way up to /. This caused directoryChanged to fire on any filesystem activity anywhere on the system, triggering full rescans of all desktop entries at ~3 Hz. Replace addPathAndParents with a plain watcher.addPath so only the actual desktop entry directories are watched. Subdirectory monitoring (scanAndWatch) is unaffected. Idle CPU drops from ~45% to ~3-5% on affected systems. The spurious 'Directory change detected' log spam stops entirely.
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.
Problem
DesktopEntryMonitor::startMonitoring()callsaddPathAndParents(), which addsQFileSystemWatcherwatches on every parent directory of each desktop entry path — all the way up to/. For example, for/usr/share/applicationsit watches/usr/share,/usr, and/.Watching
/meansQFileSystemWatcher::directoryChangedfires on any filesystem event anywhere on the system — a temp file in/tmp, a cache write, a.configchange — triggering a full rescan of all desktop entries. This causes:.desktopfile has changedlog.qsloggrowing to multiple GB from "Directory change detected" spam$XDG_RUNTIME_DIR(reported to fill 3.2 GB in ~16 h)Fix
Replace
addPathAndParents()with a plainwatcher.addPath(path)so only the actual desktop-entry directories are watched.scanAndWatch()independently handles subdirectory monitoring.Result
Measured on NVIDIA RTX 4090, Hyprland (Wayland), Arch Linux, Qt 6.11, ~366 .desktop files:
.desktopdir changes trigger rescanRelated
Closes #757 — "DesktopEntries fires spurious rescan events, growing log.qslog by multiple GB"