Home » Linux » Comprehending 'top' CPU usage [closed]

Comprehending 'top' CPU usage [closed]

Posted by: admin November 29, 2017 Leave a comment

Questions:

What does it exactly mean to have a 350% cpu usage (by a process) on a
4-CPU box? The process is a ‘mysqld’ which is currently being
‘bombarded’ by a simulated OLTP scenario.

Any pointers appreciated.

Answers:

In *NIX land, 100% cpu usage is 100% of a SINGLE cpu.

This applies to multi-core processors the same way as true multi-processor computers.

So, you are using 7/8th of your total CPU cycles on mysql.

Questions:
Answers:

While running top, press “1”. This will toggle the view so that you can see the load per individual core/cpu.

Questions:
Answers:

I’ve just read an interesting article on this very subject yesterday : Unix load average. It will explain all you need to know and more.

Extract :

The load average is the sum of the run queue length and the number of jobs currently running on the CPUs. In Solaris 2.0 and 2.2 the load average did not include the running jobs but this bug was fixed in Solaris 2.3.

Consider that there are two basic modes to display load : “IRIX mode” and “Solaris mode”. In IRIX mode (Linux default), a load average of 1 means that one CPU is fully loaded ( or 25% of each CPU on a 4 CPU system, etc). In Solaris mode, a load average of 1 means that all CPUs are fully loaded (so it’s actually equivalent to “IRIX mode” load divided by CPU count ).

Questions:
Answers:

Load average shows how many processes are waiting on the queue (adjusted for the number of CPUs). With one CPU, a load average of 1.0 means that this CPU is able to fully process all requests on the queue optimally — no process is waiting for CPU, and no CPU cycles are wasted (i.e. idle). A load average of 2.0 (on a single-core system( would mean that half the processes would be waiting for a chance to run on the CPU 🙁 A load average of 0.33 would mean that there is so little load on the system that 2/3 of the time the CPU is basically doing nothing but waiting for more processes to run.

The CPU percentage shown by top is a measure of how often a single process is loaded by the kernel to run on the CPU, averaged over a period of time. So 350% on a 4-core system means that, for a period of time, mysqld would be taking over three full CPUs and half the time of the fourth CPU — i.e. it has so many threads to run that it pretty much swamps the 4 cores with requests. CPU percentage doesn’t really take into account the waiting queues (while load average does): it’s an after-the-fact statistic of what happened in a certain frame of time. But it certainly shows which processes have been using the CPU(s) recently.

Another thorough article on the same subject: http://www.linuxjournal.com/article/9001

Questions:
Answers:

There are 4 x 100%, so “top” shows a total of 400% on a 4 CPU box.

Questions:
Answers:

Each cpu process is consider as 100% . So totatlly it 400% of 4 cpu.