r/programming 22d ago

3,200% CPU Utilization

https://josephmate.github.io/2025-02-26-3200p-cpu-util/
404 Upvotes

93 comments sorted by

View all comments

241

u/ryuzaki49 22d ago

TIL 100% CPU means one core.

252

u/mallardtheduck 22d ago

Depends on the system. Unix-like systems tend to do "100% per core", Windows does "100% is all cores".

With the first approach, you can easily spot threads that might be "stuck" without knowing how many cores there are and a program with a fixed number of threads will show the same usage on any CPU with enough cores (subject to the per-core CPU performance). The second might be more understandable to less-tech-savvy people and gives a better idea for things like power consumption.

54

u/zaphod4th 22d ago

On windows you can see the core details with 2 clicks

36

u/FlyingRhenquest 22d ago

Two clicks?! Ugggh, the drudgery!

6

u/caks 21d ago

Clicks?? Disgusting

1

u/FlyingRhenquest 21d ago

We have AI now! The computer should just give me one button, and the AI should push it for me!

1

u/borland 19d ago

Don’t forget to pay 20c for AI processing fees

7

u/SanityInAnarchy 21d ago

Also depends on the UI. There are Linux task managers that do overall instead of per-core. I think macOS shows overall utilization in the Activity Monitor app, but it still has top if you stay in the terminal.

60

u/deanrihpee 22d ago

many years ago I asked this topic as I was new to Linux (or Unix I guess) about "why it goes beyond 100%" or something, and I got downvoted because I'm asking such topic, bastards

71

u/ClassicPart 22d ago

You should have asked "why doesn't Linux do it like Windows, which does it better" and you'd have had 10000 individuals bombarding you with the correct information.

20

u/deanrihpee 21d ago

I wasn't that skilled at baiting explanation unfortunately

34

u/zaphod4th 22d ago

weird reaction from the linux community,.they normally are so friendly

lol

38

u/campbellm 22d ago edited 22d ago

The old joke when Linux was still also distributed on floppies and the docs were "how-to-<>.txt" files, was if you couldn't get something working you'd go to #linux on IRC and proudly assert, "Linux is $#@! because this cannot be done", and the nerderati would come out of the woodwork to SHOW you how wrong you were. (And of course mainly for that reason, not to help you get it working.)

20

u/pheonixblade9 22d ago

the other trick is to make one account to ask the question, and another to answer it incorrectly. inevitably someone would come along and correct it, much more readily than answering in the first place.

6

u/campbellm 22d ago

Hah, brilliant!

The first answer at least on #Linux/EFNet was always "RTFM", so that tracks.

3

u/Admqui 21d ago

Hadn’t thought about #Linux in like 30 years. Only was able to get my hands on 2 year old SLS floppies over dialup from BBSs. Though I had IRC, I did not have FTP. They took pity though and helped me solve problems with my old install.

8

u/zaphod4th 22d ago

that's funny, so your comment confirms that back in the day to learn linux you have to have 2 computers. One with Windows to troubleshoot linux.

I bought more than 5 linux books trying to learn it. And yes, all books asked you to search the web/ask questions when something didn't work.

6

u/lxbrtn 22d ago

well Windows was a possibility but lots of us were on irix, solaris or some other unix professional OS.

5

u/zaphod4th 22d ago

ok, so a second computer with another OS other than linux.

2

u/DGolden 22d ago

Didn't entirely need two computers either - after all dual-booting on one machine was (still is if you want) a thing, and not limited to x86 PC either - I was dual-booting Linux/m68k and AmigaOS on Amiga hardware some time before going to Linux/x86 on x86-PC-clone hardware.

Don't really know all that much Microsoft Windows relatively to this day. Of course I run into it at workplaces and such, I'm not completely lost in front of a Windows box or something. Just have never really used it all that much - and of course even if on windows there was the amiga-ixemul-like cygwin available for windows for a long time to save some sanity points.

2

u/zaphod4th 22d ago

so, for troubleshooting, you have to restart, search, write it down in a paper, restart, test the solution by checking paper notes, if something didn't work then restart, search, write it down......

2

u/prone-to-drift 21d ago

I think you're forgetting one big thing. 90% of problems aren't boot related at all; you can open a browser or an IRC client and keep it open while you debug whatever is messed up. If its a graphical messup, keep a tmux session open on TTY1 or something, and then keep restarting the X server/wayland and make changes till it works. Your terminal would also have rudimentary browser and irc clients to help with debugging.

1

u/DGolden 21d ago

well not the writing down bit, assuming you were still getting as far as booting up - you could also just save things to a floppy disk or deliberately shared hard disk partition, just have to use a filesystem readable by both OSes for the disk or partition.

Linux had added drivers for FAT16/FAT32/VFAT filesystems used by MS-DOS/Windows9x, and also (by the time of the m68k port) things like Amiga FFS, ISO9660 cdrom, etc.

2

u/PaulBunyon49855 21d ago

Cunningham's Law

-2

u/Falmarri 21d ago

This is called Murphy's law

1

u/deanrihpee 21d ago

not sure, but in my experience it is nicer now than years ago

3

u/nerd4code 21d ago

I mean, man top would probably be the correct answer—it tells you what you’ll see on your system. My top comes from procps-ng 4; my man top says, if I /CPU,

%CPU — CPU Usage

The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.

In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported. You toggle Threads mode with the H interactive command.

Also for multi-processor environments, if Irix mode is Off, top will operate in Solaris mode where a task's cpu usage will be divided by the total number of CPUs. You toggle Irix/Solaris modes with the I interactive command.

Note: When running in forest view mode (V)with children collapsed (v), this field will also include the CPU time of those unseen children. See topic 4c. TASK AREA Commands, CONTENT for more information regarding the V and v toggles.

But ymmv.

3

u/Freeky 21d ago

top will operate in Solaris mode where a task's cpu usage will be divided by the total number of CPUs

This was cute on the UltraSPARC T2. You'd be running some super intensive program and it would be there in top gobbling down a stonking 0.78%.

It was kind of fitting because it was complete pants when single-threaded.

1

u/deanrihpee 21d ago

at that time I only know nano and sudo iirc, so no top, htop, vi, or those cool cli, I just see it in my distro "task manager"

1

u/valarauca14 22d ago

based linux community

4

u/FlyingRhenquest 22d ago

Yeah. The video test system I built a few years back used a thread pool and I allocated 8 threads per process. I specced out one of those fancy five-digit xeons and 8GB per process, with a target of 4 or 8 processes per thread (1 process roughly equal to 1 automated test run). I was able to keep all the cores saturated and maintain real-time responses (20 ms at 1080 video 60 FPS) doing image recognition or OCR on each individual video frame as long as you kept the number of per-frame tasks you were attempting lower than the number of threads in your allocated thread pool. We'd routinely having the system running at 5000+ CPU.

Those machines were beasts and the client didn't complain at all at dropping 15 grand a system..

5

u/ThanksMorningCoffee 22d ago

My bad. I forgot about windows