Bug 440310

Summary: In plasma-systemmonitor, on 12-thread CPU, "Core 11" and "Core 12" sensors sort above "Core 3"
Product: [Applications] plasma-systemmonitor Reporter: nyanpasu64 <nyanpasu64>
Component: generalAssignee: KSysGuard Developers <ksysguard-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: ahiemstra, bugs.kde.org, kde, kde, nate, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.22.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.26
Sentry Crash Report:
Attachments: Screenshot of the CPUs sensor group list.

Description nyanpasu64 2021-07-26 21:36:06 UTC
Created attachment 140345 [details]
Screenshot of the CPUs sensor group list.

SUMMARY
On my 12-thread CPU, when I try adding CPU statistics to a plasma-systemmonitor graph, the sorting order of my CPU cores is incorrect.

STEPS TO REPRODUCE
1. Open plasma-systemmonitor.
2. Click "Add New Page..." and "Add".
3. Click the "System Monitor Sensor", and in the right sidebar, click Total Sensors or Sensors.
4. Click "CPUs" and look at the list of sensor groups.

OBSERVED RESULT
The sort order is "All, Core 1, Core 2, Core 11, Core 12, Core 3..., Core 10, [Group] CPU".

EXPECTED RESULT
Cores are sorted in numeric order (I think)?

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.22.3
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.2
Kernel Version: 5.13.4-zen2-1-zen (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GT 730/PCIe/SSE2

ADDITIONAL INFORMATION
I don't know where the order comes from, or if there's a technical explanation for the strange order. I don't think the 5600X is NUMA, so that shouldn't be it.
Comment 1 David Redondo 2021-07-27 09:41:46 UTC
We sort the ids lexicographic, what we should do is sort the visible strings
Comment 2 Bug Janitor Service 2021-08-30 08:04:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/15
Comment 3 Arjen Hiemstra 2022-05-06 11:47:41 UTC
*** Bug 453192 has been marked as a duplicate of this bug. ***
Comment 4 Arjen Hiemstra 2022-06-13 14:59:23 UTC
Git commit debcb7ce19068fb5798c343d3bd572eaef4de0a7 by Arjen Hiemstra.
Committed on 13/06/2022 at 14:49.
Pushed by ahiemstra into branch 'master'.

Sensors: Port SensorTreeModel to std::map so we can use a custom compare

Currently, the tree ends up being sorted with numbers sorted as
characters. Since the sorting happens in the map, if we want to sort
things differently we need to override the sorting function. QMap does
not support that so use std::map instead with a custom compare object.

M  +56   -21   sensors/SensorTreeModel.cpp

https://invent.kde.org/plasma/libksysguard/commit/debcb7ce19068fb5798c343d3bd572eaef4de0a7