perf(server): reduce Windows WMI polling - #4339
Conversation
- Load process and performance data with two bulk WMI queries instead of one query per process. - Increase the background resource sampling interval from five to fifteen seconds. - Add focused Windows query coverage and update CPU-time expectations.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
ApprovabilityVerdict: Needs human review The polling interval change from 5s to 15s is a meaningful runtime behavior modification affecting monitoring responsiveness, not just an internal optimization. This warrants human review to ensure the reduced granularity is acceptable. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Why
The diagnostics poller issued one additional WMI query for every process on every sample. On Windows this caused sustained WmiPrvSE CPU usage and repeated failed IDProcess queries.
Closes #4024
Checklist
Note
Low Risk
Diagnostics-only changes on Windows WMI and slower background sampling; no auth, data, or API contract changes beyond approximate CPU rollup timing.
Overview
Cuts Windows process diagnostics cost by replacing per-process WMI performance lookups with two bulk
Get-CimInstancequeries and a PID→CPU map in the PowerShell one-liner, instead of an N+1-Filterquery per process.Background resource sampling interval moves from 5s to 15s; rollup tests now expect higher
cpuSecondsApproxbecause that metric uses the new interval.A regression test asserts a single
powershell.exespawn per sample, exactly twoGet-CimInstancecalls, no-Filter, and use of$perfById.Reviewed by Cursor Bugbot for commit e4fe092. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reduce Windows WMI polling frequency and eliminate per-process CIM queries
readWindowsProcessRows(ProcessDiagnostics.ts) to fetch allWin32_PerfFormattedData_PerfProc_Processdata in a singleGet-CimInstancecall, building a$perfByIdlookup instead of issuing a filtered query per process.SAMPLE_INTERVAL_MSin ProcessResourceMonitor.ts from 5,000 ms to 15,000 ms, tripling the time between samples.Macroscope summarized e4fe092.