perf: threaded sensor sampling, GPU probe backoff, cooperative shutdown - #17
Merged
Conversation
- SensorWorker QThread samples at the configured interval and emits results via a queued signal; painting and dragging are never blocked by probes - Windows GPU counters filter engtype_3D server-side and back off 30 s after a slow probe, serving cached values meanwhile (was ~5 s per tick here) - nvidia-smi PATH lookup cached once; WMI connections created lazily and reused - empty GPU counter sets now report Unavailable instead of 0% - cooperative cancellation lets shutdown skip remaining heavy probes
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.
Summary
Fixes the two Windows symptoms from testing: sluggish HUD dragging and fans ramping on launch. Both shared one root cause.
Root cause (measured): every sample ran
Win32_PerfFormattedData_GPUPerformanceCounters_GPUEnginesynchronously on the GUI thread whennvidia-smiis absent — 3.7–7.0 s per query, 358 COM instances, at a 1000 ms default interval. One core sat pegged (fans) while mouse/paint events queued behind WMI calls (drag lag).Fixes
SensorWorker(QThread, low priority) owns the reader, samples at the configured interval, and pushes results to the HUD over a queued signal — painting/dragging never wait on probesengtype_3Drowsnvidia-smiPATH lookup cached once; WMI connections created lazily and reused; empty counter sets report Unavailable instead of 0%wait(5000)used to time out behind a live enumeration)Measured impact (Windows 11, no NVIDIA, i+dGPU)
First cold sample remains slow (~6 s provider warmup) but runs off-thread once.
Docs
DocsHub maintenance page updated in lockstep (threaded sampling + backoff wording).
Testing
ruff format --check ./ruff check .passpytest -qoffscreen: 18 passed (5 new tests: backoff, server-side filter + empty-set semantics, one-time PATH resolution, cooperative cancellation, worker stop)