Why does apt-get NOT use 100% (cpu OR disk OR net)?

Apps will only max out the CPU if the app is CPU-bound. An app is CPU-bound if it can quickly get all of its data and what it waits on is the processor to process the data.

apt-get, on the other hand, is IO-bound. That means it can process its data rather quickly, but loading the data (from disk or from the network) takes time, during which the processor can do either other stuff or sit idle if no other processes need it.

Typically, all IO requests (disk, network) are slow, and whenever an application thread makes one, the kernel will remove it from the processor until the data gets loaded into the kernel (=these IO requests are called blocking requests).


Even on a slow system (Raspberry Pi 2+) I'm getting at most 30% CPU load.

The Raspberry Pi 2+ has 4 cores. For some monitoring tools, a 100% usage correspond to all the cores been used at 100%. If only one core in a quad code processor is used, the CPU load is 25 %. The 30% CPU load you mention is roughly one core used at 100% while some processes are running on the other cores:

(100% on one core out of 4 = 100 / 4 = 25%) + some processes ≃ 30%

Since apt-get is not multi threaded, it will never use more than one processor, which is 25% of all the CPU resources.


Here is an example on my 8 cores (4 cores with Hyper-Threading) machine running Ubuntu, I launched one thread with the cat /dev/zero > /dev/null command in order to create an infinite process that utilize one core entirely.

Now if we take a look at the graph from htop, we can see that the average load (Avg bar) is 12.7%, which correspond to one core used at 100%, which is also 1/8 of all the CPU resources:

(100% = 100 / 8 = 12.5%) + some background processes ≃ 12.7%.

htop

It can also be noted that the command has a value of 100% in the CPU% column, this is because it's relative to one core and not to all the cores.


I think you're actually not measuring IO %. I haven't seen a Linux IO% widget. (I'm very envious of the Windows 10 task manager :). Check using the iotop command and you will see 100% IO.

top should show 100% across user+system+iowait, for values of 100% divided by your core count as described by A.L. I'm not saying top is 100% helpful, but it can be a really useful all-around tool to learn.

Throughput will be lower than maximum, because you're unpacking lots of small files, aka "random IO". There's also some disk sync / cache flushes, although since 2010 on Linux there's only a few of them for each package installed. (Used to be one per file).

Tags:

Cpu Usage

Apt