flightlessmango / MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb
MIT License
6.44k stars 287 forks source link

Feature request: Display highest-load CPU thread/core #800

Open LuminairPrime opened 2 years ago

LuminairPrime commented 2 years ago

It's common to have a "CPU utilization" value calculated as an average utilization across all logical CPU threads (as displayed in Windows Task Manager), but this is of limited use to the observer unless they are using applications which scale across many threads. Most applications DON'T scale across many threads, so you can end up with an uncomfortable situation where a 16 thread CPU is delivering maximum possible performance to an application yet the "CPU utilization" only says "6%". Compounding this poor communication is how Windows can rapidly move software threads around to different hardware threads, precluding the observer from pinning one logical thread for monitoring, confusing monitoring application algorithms, and obfuscating the true single-thread CPU load and application usage. As new CPUs are delivered with more cores and threads, this problem is amplified, and common "CPU utilization" monitoring becomes useless, with many tasks not being visible on utilization graphs despite clocking up a CPU to maximum boost and fully using one thread or core.

I propose a novel "max CPU single-thread utilization" (MCSTU) metric and accompanying "max CPU single-thread utilization application" metric for monitoring applications, so people can see when their CPU is being used, and by what application. These are complimentary to the "average" CPU and GPU utilization values commonly shown in monitoring applications ever since the days of 1-core CPUs where the average and the max was the same thing. Note the same phenomenon of average equaling max in many-core GPUs where all applications are maximally threaded.

Thank you for reading!

jackun commented 2 years ago

Or all per core usage summed?

diff --git a/src/cpu.cpp b/src/cpu.cpp
index 035fd1a..ae819a7 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -185,6 +185,7 @@ bool CPUStats::UpdateCPUData()
             &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice) == 10) {
             ret = true;
             calculateCPUData(m_cpuDataTotal, usertime, nicetime, systemtime, idletime, ioWait, irq, softIrq, steal, guest, guestnice);
+            m_cpuDataTotal.percent = 0;
         } else if (sscanf(line.c_str(), "cpu%4d %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu",
             &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal, &guest, &guestnice) == 11) {

@@ -209,6 +210,7 @@ bool CPUStats::UpdateCPUData()
             calculateCPUData(cpuData, usertime, nicetime, systemtime, idletime, ioWait, irq, softIrq, steal, guest, guestnice);
             cpuid = -1;
             cpu_count++;
+            m_cpuDataTotal.percent += cpuData.percent;

         } else {
             break;