stevepedwards.com/DebianAdmin linux mint IT admin tips info

CPU Bound Loop to Load 1 CPU Core to 100% to Test Observability Tools

This is a simple while loop to load a single core of a multi-core CPU so there is a reference load for any tools you may need to test observability function:

 while :; do :; done

Here it is running on my quad core laptop using SysMon's viewer. You can see core 4 rising to 100% utilisation when the loop runs.

 
What is interesting about this though is the "arbitrary" choice of core as shown by the video below running it twice on a dual core PC. It runs on CPU0 first and loads it to 100%, then on CPU1.

The same happened above when I ran it on the 4 core laptop above - it loaded CPU core 4 first time, then CPU core 1 the 2nd and 3rd time.

 

The numbers from iostat below also seem to show one core fully loaded for different systems:

My quad core with nothing but the OS running with the while loop, and iostat for the numbers shows 1/4 of total CPU cores loaded as you may expect:

IOSTAT 1

Quad Core Laptop iostat -c 1

avg-cpu: %user %nice %system %iowait %steal %idle
                26.32 0.00      0.25 0.00 0.00               73.43

On the dual core below, the numbers also make sense, as load avg (across both cores) rises to about 55% total, as 1 core should be at 50% (full loaded) but there is still idle time - on the other core I assume. The system only accounts for 0% amazingly.

Dual Core Dell64  iostat -c 1

avg-cpu: %user %nice %system %iowait %steal %idle
                 55.50 0.00     0.00 0.00 0.00                  44.50

Dual Core HP64 - seems to verify the single core saturation

 iostat -c 1

avg-cpu: %user %nice %system %iowait %steal %idle
                 53.23 0.00 1.00 0.00 0.00                     45.77

Single Core Celeron32 - can never reach 100% as the system requires CPU access also.

avg-cpu: %user %nice %system %iowait %steal %idle
                 91.00 0.00 9.00 0.00 0.00 0.00

So that seems to verify the use of the loop as a reference for observability tools function and accuracy. You can use it as a baseline for future system readings - for iostat at least. But do other tools show the same loading?

MPSTAT 1

Quad Core no loop/with loop: mpstat 1

Average: all 16.67 0.00 3.47 0.94 0.00 0.05 0.00 0.00 0.00 78.87

Average: all 26.93 0.00 0.28 0.13 0.00 0.00 0.00 0.00 0.00 72.65

Single Core Celeron32 no loop/with loop: mpstat 1

Average: all 14.62 0.00 5.65 7.81 0.00 0.00 0.00 0.00 0.00 71.93

Average: all 95.52 0.00 4.48 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Dual Core Dell64 no loop/with loop: mpstat 1

Average: all 8.74 0.00 1.76 0.50 0.00 0.00 0.00 0.00 0.00 89.00

Average: all 57.04 0.00 0.96 0.59 0.00 0.00 0.00 0.00 0.00 41.41

Dual Core HP64 no loop/with loop: mpstat 1

Average: all 4.74 0.00 2.21 0.63 0.00 0.00 0.00 0.00 0.00 92.42

Average: all 52.71 0.00 1.31 0.37 0.00 0.00 0.00 0.00 0.00 45.60

Seems to verify the loop for mpstat also.

SAR 1

Quad Core no loop/with loop:  sar 1

Average: all 3.33 0.00 0.74 0.30 0.00 95.63

Average: all 26.65 0.00 0.50 0.54 0.00 72.30

Dual Core Dell64 no loop/with loop: sar 1

Average: all 8.54 0.00 1.66 0.61 0.00 89.20

Average: all 57.16 0.00 0.68 0.54 0.00 41.62

Dual Core Dell64 no loop/with loop: sar 1

Average: all 5.16 0.00 3.08 0.25 0.00 91.51

Average: all 53.05 0.00 1.35 0.08 0.00 45.53

Single Core Celeron32 no loop/with loop: sar 1

Average: all 12.89 0.00 7.70 6.86 0.00 72.55

Average: all 96.05 0.00 3.95 0.00 0.00 0.00

Ok, I'm happy they all function similarly enough to show the loop loads a single core to its max, with appropriate readings for that core as a proportion of the total cores available. I assume these tools get their data from the same kernel functions anyway, so would expect similar data.

5/10/16 There is a very important thing to note with CPU utilization and a Vidia graphics card without hardware acceleration due to no nVidia drivers being available/installed for a particular system - as the screen "software rendering" warning box tells you; look at the extra overhead the CPU incurs on my latest HP dual core Intel tower, with 2GB ram and an uncommon NV17GL [Quadro NVS] PCI card, when running only the screensaver compared to screensaver idle on the other PCs that have a hardware module loaded - 70% when it should be about 8%!

iostat -c 1
Linux 3.16.0-38-generic (intelmint) 05/10/16 _x86_64_ (2 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
68.51 0.00 5.87 2.84 0.00 22.78

avg-cpu: %user %nice %system %iowait %steal %idle
76.50 0.00 5.50 0.00 0.00 18.00

avg-cpu: %user %nice %system %iowait %steal %idle
79.00 0.00 4.00 0.00 0.00 17.00

avg-cpu: %user %nice %system %iowait %steal %idle
77.00 0.00 5.00 0.00 0.00 18.00

avg-cpu: %user %nice %system %iowait %steal %idle
78.28 0.00 5.05 0.00 0.00 16.67

avg-cpu: %user %nice %system %iowait %steal %idle
81.09 0.00 3.98 0.00 0.00 14.93

Comments are closed.

Post Navigation