Clint Rutkas 8056ba0972 CmdPal: Fix double-speed Performance Monitor histories and long GPU names (#51206)
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

Independent PR split out of #51125, which redesigns the Performance
Monitor cards; see it for the full picture. This PR can merge in any
order with the rest of that split.

It fixes two Performance Monitor bugs on `main`:

- **A metric shown in two places records its history at double speed.**
For example, with the Memory dock band pinned and the Performance
Monitor page open, two one-second timers each add a point to the same
chart history, so the chart fills twice as fast and covers half the time
it should. Now every metric (CPU, memory, network, disk, GPU, and
battery) gets one sample per second, however many places show it.
- **Some GPU names make the dock label too long.** Some drivers append
details in parentheses: `NVIDIA RTX Spark N1X (6144-core Blackwell RTX
GPU)` showed as `RTX Spark N1X (6144-core Blackwell RTX GPU)`. It now
shows as `RTX Spark N1X`.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [ ] Closes: N/A. Split out of #51125.
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized (no
new strings)
- [ ] **Dev docs:** Added/updated (N/A)
- [ ] **New binaries:** Added on the required places (N/A: no new
binaries or projects)
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx (N/A)

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

### Double-speed histories

On `main`, `PerformanceMonitorCommandsProvider` creates the main page,
the combined dock band, and a dock band for each metric. Each is a
`PerformanceWidgetsPage` with its own `SystemXxxUsageWidgetPage` for
each metric it shows, and each of those has its own `DataManager` with a
one-second timer that runs while the page or band is shown. Every
`DataManager` samples the same `SystemData.Shared` stats, and for CPU,
memory, network, disk, and GPU, each sample appends a point to the
shared chart history (`ChartHelper.AddNextChartValue`). So each extra
place that shows a metric adds another point per second.

`DataManager.ShouldSample` records when each stats object was last
sampled, in a `ConditionalWeakTable` keyed by the stats object, and
skips the sample if the last one was less than 750 ms ago. The check
runs under the stats lock that each sampler already takes. 750 ms leaves
room for timer jitter: a late tick from the same timer still samples,
but a second timer's tick within the same second doesn't. Every timer
still calls its page's update, so every place keeps showing the latest
values.

All six metrics are gated: CPU, memory, network, disk, GPU, and battery.
Every CPU page on `main` uses `DataType.CPU`, so all CPU timers ask for
the same sample; `includeTopProcesses` and
`DataType.CpuWithTopProcesses` are unchanged.

### Long GPU names

`GpuAdapterNames.GetShortName` removes known branding, such as `NVIDIA`,
`GeForce`, `(R)`, `(TM)`, and a trailing ` GPU`. Nothing removed a
trailing part in parentheses, so it stayed in the label. It's now
dropped before the other rules run, so they see the model name. Names
without one are unchanged.

### Tests

- `DataManagerTests` (new) covers `ShouldSample`: the first sample, a
second timer within the same second, a late tick, and separate schedules
for each stats object.
- `GpuAdapterNamesTests` gets a row for `NVIDIA RTX Spark N1X (6144-core
Blackwell RTX GPU)`.

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

ARM64, Debug, from the repo root:

- `MSBuild.exe
src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.PerformanceMonitor\Microsoft.CmdPal.Ext.PerformanceMonitor.csproj
-nologo -m -restore -t:Build -v:minimal -p:Configuration=Debug
-p:Platform=ARM64 -p:RuntimeIdentifier=win-arm64 -p:CIBuild=false
-p:GeneratePackageLocally=false -p:GenerateAppxPackageOnBuild=false
-p:PublishAppxPackage=false -p:SkipLongPathsCheck=true`: exit code 0, 0
warnings.
- The same command for
`src\modules\cmdpal\Tests\Microsoft.CmdPal.Ext.PerformanceMonitor.UnitTests\Microsoft.CmdPal.Ext.PerformanceMonitor.UnitTests.csproj`:
exit code 0, 0 warnings.
- `vstest.console.arm64.exe
ARM64\Debug\WinUI3Apps\CmdPal\tests\Microsoft.CmdPal.Ext.PerformanceMonitor.UnitTests.dll
/Platform:ARM64`: 103 passed, 0 failed, including the four new
`DataManagerTests` and the new GPU name row.
- With `main`'s `GpuAdapterNames.cs`, the new GPU name row fails:
`Expected:<RTX Spark N1X>. Actual:<RTX Spark N1X (6144-core Blackwell
RTX GPU)>`.
- A throwaway test (not in this PR) reproduced the double-speed history.
It called the samplers of two `DataManager` instances for the same
metric 500 ms apart, once per second each, for 5 seconds, with the real
`MemoryStats` and `CPUStats`:

  | Metric | History points without this PR | With this PR |
  |---|---|---|
  | Memory | 10 | 5 |
  | CPU | 10 | 5 |
2026-10-28 00:25:56 +00:00
2026-02-11 22:59:53 +01:00
2026-09-16 09:13:00 -07:00
2020-03-05 10:11:27 -08:00
2020-05-02 15:59:18 -07:00
2026-02-14 15:47:56 +08:00

Microsoft PowerToys

Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks.

Installation · Documentation · Blog · Release notes

🔨 Utilities

PowerToys includes over 30 utilities to help you customize and optimize your Windows experience:

Advanced Paste icon Advanced Paste Always on Top icon Always on Top Awake icon Awake
Color Picker icon Color Picker Command Not Found icon Command Not Found Command Palette icon Command Palette
Crop and Lock icon Crop And Lock Environment Variables icon Environment Variables FancyZones icon FancyZones
File Explorer Add-ons icon File Explorer Add-ons File Locksmith icon File Locksmith Grab And Move icon Grab And Move
Hosts File Editor icon Hosts File Editor Image Resizer icon Image Resizer Keyboard Manager icon Keyboard Manager
Light Switch icon Light Switch Mouse Utilities icon Mouse Utilities Mouse Without Borders icon Mouse Without Borders
New+ icon New+ Peek icon Peek PowerDisplay icon PowerDisplay
PowerRename icon PowerRename PowerToys Run icon PowerToys Run Quick Accent icon Quick Accent
Registry Preview icon Registry Preview Screen Ruler icon Screen Ruler Shortcut Guide icon Shortcut Guide
Text Extractor icon Text Extractor Window Hopper icon Window Hopper Workspaces icon Workspaces
ZoomIt icon ZoomIt

📦 Installation

For detailed installation instructions and system requirements, visit the installation docs.

But to get started quickly, choose one of the installation methods below:

Download the .exe file from GitHub

Go to the PowerToys GitHub releases, scroll down and select Assets to reveal the installation files, and choose the one that matches your architecture and install scope. For most devices, that would be x64 per-user.

Microsoft Store
You can easily install PowerToys from the Microsoft Store:

WinGet
Download PowerToys from [WinGet](https://github.com/microsoft/winget-cli#installing-the-client). Updating PowerToys via winget will respect the current PowerToys installation scope. To install PowerToys, run the following command from the command line / PowerShell:
  • User scope installer (default)
winget install Microsoft.PowerToys -s winget
  • Machine-wide scope installer
winget install --scope machine Microsoft.PowerToys -s winget
Other methods
There are [community driven install methods](https://learn.microsoft.com/windows/powertoys/install#community-driven-install-tools) such as Chocolatey and Scoop. If these are your preferred install solutions, you can find the install instructions there.

✨ What's new?

What's new image

To see what's new, check out the release notes.

🛣️ Roadmap

For v0.103, we're working on a new Awake flyout, improving Screen Ruler, and continuing to modernize more utilities with WinUI 3.

❤️ PowerToys Community

The PowerToys team is extremely grateful to have the support of an amazing active community. The work you do is incredibly important. PowerToys wouldn't be nearly what it is today without your help filing bugs, updating documentation, guiding the design, or writing features. We want to say thank you and take time to recognize your work. Your contributions and feedback improve PowerToys month after month!

Contributing

This project welcomes contributions of all types. Besides coding features / bug fixes, other ways to assist include spec writing, design, documentation, and finding bugs. We are excited to work with the power user community to build a set of tools for helping you get the most out of Windows. We ask that before you start work on a feature that you would like to contribute, please read our Contributor's Guide. We would be happy to work with you to figure out the best approach, provide guidance and mentorship throughout feature development, and help avoid any wasted or duplicate effort. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you grant us the rights to use your contribution and that you have permission to do so. For guidance on developing for PowerToys, please read the developer docs for a detailed breakdown. This includes how to setup your computer to compile.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct.

Privacy statement

The application logs basic diagnostic data (telemetry). For more privacy information and what we collect, see our PowerToys Data and Privacy documentation.

Languages
C 39.9%
C# 31.3%
C++ 13.6%
JavaScript 12.5%
PowerShell 2.3%
Other 0.3%