Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please use Processor Time instead of Processor Utility for CPU utilization in Task Manager #78

Closed
ysc3839 opened this issue Jan 27, 2021 · 10 comments

Comments

@ysc3839
Copy link

ysc3839 commented Jan 27, 2021

Environment

Item Value
OS, Version / Build 10.0.19042.0
Processor Architecture AMD64
Processor Type & Model AMD Ryzen 7 4800U with Radeon Graphics, 1800 Mhz, 8 Core(s), 16 Logical Processor(s)
Memory 16GB
Storage Type, free / capacity (e.g. C: SSD 128GB / 512GB) SSD 512GB
Relevant apps installed N/A

Description

According to this page, starting with Windows 8, the CPU utilization in Task Manager correspond to the Processor Utility.
However this makes no sense for developers, since developers are interested in how much CPU time their program use, not "the actual work that the processor performs".
And since the value is cutoff to 100% in Task Manager, it's useless for someone who interested in Processor Utility. (See screenshot)

Feedback Hub link: https://aka.ms/AAaxq8k

Steps to reproduce

Run while(1){} in PowerShell and see PowerShell CPU usage in Task Manager.

Expected behavior

The CPU usage of PowerShell should be 100/n% where n is logical processors count.

Actual behavior

The CPU usage of PowerShell is more than 100/n%.

@ghost ghost added the Needs-Triage 🔍 label Jan 27, 2021
@randomascii
Copy link

I 100% agree. Processor utility is very difficult to reason about. If Task Manager says that I'm using 60% of CPU then that could mean that my CPU cores were in use over the previous period for 60% of the time. Or, it could mean that my CPU cores were busy 100% of the time and my CPUs were running at 60% of the time, due to thermal or power throttling.

In the first case my system has headroom, should be responsive, and if I want my code that is running to complete faster I need to get rid of the idle time.

In the second case my system does not have headroom, is probably sluggish and unresponsive, and if I want my code that is running to complete faster I need to plug in my computer or clean the fans or put it in a cooler room.

@Trentent
Copy link

I just experienced this exact issue.

My CPU % was reported to be only 3% but due to thermal throttling my CPU was running at 300Mhz... So I was having extremely poor performance and the 3% was not reflective of the actual experience.

https://twitter.com/TrententTye/status/1363550869501800448

@dmex
Copy link

dmex commented Feb 26, 2021

The CPU usage of PowerShell should be 100/n% where n is logical processors count.

That's an incorrect and misleading counter because processes are multi-threaded on Windows while on Linux processes are single-threaded and so times/dividing those counters on Windows based on logical processors instead produces a garbage counter which is meaningless because the scheduler can and does switch the threads onto different cores/processors.

Process Explorer/Process Hacker and other third party software instead calculate the utilization based on the cycles which is a lot more accurate because cycles takes into consideration the available cycles which are limited by throttling/power management.

Task Manager should instead be using cycle counters for calculating the utilization similar to Process Explorer and third party software.

AMD Ryzen 7 4800U

It's likely those AMD processors have issues that are screwing up the counters which haven't been fixed yet:
https://i.imgur.com/36C9tPU.png

@randomascii
Copy link

That's an incorrect and misleading counter because processes are multi-threaded on Windows

No, the OP's point is correct. If a single process is running a single thread and that thread is in a busy loop then (assuming that the system is otherwise idle) it is desirable and useful to display the CPU usage as 100/n%, where n is the logical processor count. The fact that processes on Windows might have multiple threads is not relevant for this thought experiment. If the busy thread of that process gets moved to a different processor then that is irrelevant. The point is that the average processor time used is 100/n% of the total available processor time.

A case could be made for having 100% CPU usage mean that a single logical processor is completely busy, while 800% would mean that eight logical processors are completely busy (this is the meaning that Chrome has switched to) but I suspect that such a change is too radical for Windows. That would be a separate bug.

The problem with using cycles, and adjusting for cycles available, is that it makes the result ambiguous. I have seen my CPU listed as 30% busy in Task Manager when running CPU intensive tasks on all logical processors. The 30% happens because my laptop battery cannot provide enough power to run the CPU at full speed, but it is difficult for me to determine that.

To me, 30% implies that 70% of cycles on my processors are unused. However Task Manager uses 30% to mean that it believes the CPU could handle more work. The problem is that its belief is sometimes incorrect. If a CPU is thermally throttled (as @Trentent experienced) or power throttled (as I have experienced) then a 3% or 30% reading in Task Manager represents a CPU that is running as fast as it can without hardware intervention. It makes little sense for 3% or 30% to represent a CPU that is 100% busy and can handle no additional work.

I have yet to see a compelling argument for the new meaning and I hope that it is changed back to the old meaning, which was much more useful.

@dmex
Copy link

dmex commented Feb 27, 2021

a single process is running a single thread and that thread is in a busy loop

Windows processes have not been single threaded for over 30 years. The loader creates thread pools for loading imported dlls during process creation, COM and RPC create threads for marshalling parameters cross processes, performance counters create threads for caching/calculating counters, winsock creates threads for pipes and IO completion ports, win32k creates threads for injecting DLLs when other processes on the machine use functions like SetWindowsHookEx not to mention kernel threads for APC callbacks, timers, exception handling etc...

The problem with using cycles, and adjusting for cycles available, is that it makes the result ambiguous. I have seen my CPU listed as 30% busy in Task Manager when running CPU intensive tasks on all logical processors. The 30% happens because my laptop battery cannot provide enough power to run the CPU at full speed, but it is difficult for me to determine that.

Laptops are a different problem entirely. OEMs modify the hardware with batshit crazy optimizations for batteries in undocumented and non-standard methods without reflecting those 'optimizations' in the hardware counters. It's not possible to accurately reflect the utilization of laptops because of those changes and there's nothing anyone can do about it because they violate standards.

Cycles are a more accurate representation of utilization which is why they're used across every third party product on Windows. You'll only run into problems with this on laptops because of their insane non-standard modifications to the hardware.

800% would mean that eight logical processors are completely busy

image

What does this value represent? 99% of 16 cores?, 50% of 30 cores?, 10% of 160 cores? Is that code operating at peak efficiently or at minimal efficiently? Is that code utilizing the full extent of my hardware or a minimal amount of my hardware?

image

What does this value represent? 98% of 16 cores, 45% of 30 cores?, 9% of 160 cores? Is that code operating at peak efficiently or at minimal efficiently? Is that code utilizing the full extent of my hardware or a minimal amount of my hardware?

When you're dealing with fractions of a total, you should never display those values more than the total otherwise it becomes a garbage counter violating the rules of fractions. You only have one machine which is represented as 1.0 and the utilization of processes/threads are a fraction of that total.

The second graph is more accurate because I can immediately determine the code is utilizing your hardware to the fullest extent. If it was showing 800% for one machine and 800% for another machine then you would be mislead into thinking it was optimal when in fact the other machine has 2x the number of processors and there's a major performance problem.

This is why no software on Windows shows "100/n% where n is logical processors count" because it's misleading an inaccurate.

@randomascii
Copy link

Windows processes have not been single threaded for over 30 years.

That doesn't matter. For this question the only relevant thing is how many threads are actively running. The OP posited a process with a single busy thread. Idle threads do not affect this question.

The second graph is more accurate

It's not a matter of accuracy, it is a matter of the desired meaning. The advantage of having 800% mean "8-cores, on average, are busy" is that it gives you a portable sense of how much work is being done. You are correct that it does not give a portable sense of what percentage of the logical processors are busy. Therefore, it is not a matter of accuracy, it is a matter of which is most useful, which is a matter of opinion. And, that opinion is not relevant to this bug. I should not have made that aside.

It's not possible to accurately reflect the utilization of laptops

Does that mean we agree? The title of this bug is "Please use Processor Time instead of Processor Utility". The OP, trentent@, and myself all find that processor utility is a confusing and non-helpful metric. We would prefer processor time. If it is impossible to accurately reflect the utilization of laptops then Task Manager should stop trying to do that.

Processor time is what ETW uses when displaying CPU usage and personally I find it far easier to work with. It is trivially obvious with ETW (and with the previous implementation of Task Manager) when your CPUs are all running code 100% of the time.

@AvriMSFT
Copy link
Contributor

This is a very valuable piece of feedback for the Task Manager team and I think the need is clear. I've gone ahead and upvoted the feedback in the Feedback Hub. Unfortunately though, this issue is out of scope for the repo and will be closed out as such. I'll track down someone from the Task Manager team about the request and put it on their radar.

@AvriMSFT AvriMSFT added the Resolution-OutOfScope Not in scope label Apr 14, 2021
@AvriMSFT AvriMSFT self-assigned this Apr 14, 2021
@randomascii
Copy link

Can you put in a link to the feedback hub item so that those who find/follow this item can upvote the feedback hub item?

@Eli-Black-Work
Copy link

@randomascii I think it's the one that's in the original post: https://aka.ms/AAaxq8k 🙂

@randomascii
Copy link

I upvoted that feedback item. Thanks for the link.

@microsoft microsoft locked as resolved and limited conversation to collaborators Jun 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants