{"id":4302,"date":"2016-08-20T23:59:25","date_gmt":"2016-08-20T22:59:25","guid":{"rendered":"https:\/\/stevepedwards.today\/DebianAdmin\/?p=4302"},"modified":"2016-08-20T23:59:25","modified_gmt":"2016-08-20T22:59:25","slug":"cpu-bound-loop-to-load-1-cpu-core-to-100-to-test-observability-tools","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/DebianAdmin\/cpu-bound-loop-to-load-1-cpu-core-to-100-to-test-observability-tools\/","title":{"rendered":"CPU Bound Loop to Load 1 CPU Core to 100% to Test Observability Tools"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4302\" class=\"pvc_stats all  \" data-element-id=\"4302\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>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:<\/p>\n<p><span style=\"color: #0000ff;\">\u00a0while :; do :; done<\/span><\/p>\n<p>Here it is running on my localhost core laptop using SysMon's viewer. You can see core 4 rising to 100% utilisation when the loop runs.<\/p>\n<p><center><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/01jYyKOvaRc?autoplay=1&amp;version=3&amp;loop=1&amp;playlist=01jYyKOvaRc\" width=\"460\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/center><span style=\"color: #0000ff;\">\u00a0<\/span><br \/>\nWhat 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.<\/p>\n<p>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.<\/p>\n<p><center><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/l0565k1MaYM?autoplay=1&amp;version=3&amp;loop=1&amp;playlist=l0565k1MaYM\" width=\"460\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/center><span style=\"color: #0000ff;\">\u00a0<\/span><\/p>\n<p>The numbers from iostat below also seem to show one core fully loaded for different systems:<\/p>\n<p>My localhost 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:<\/p>\n<p><strong>IOSTAT 1<\/strong><\/p>\n<p><strong>Quad Core\u00a0Laptop<\/strong><span style=\"color: #0000ff;\">\u00a0iostat -c 1<\/span><\/p>\n<p>avg-cpu: %user %nice %system %iowait %steal %idle<br \/>\n<strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 26.32<\/strong> 0.00 \u00a0 \u00a0 \u00a00.25 0.00 0.00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<strong>73.43<\/strong><\/p>\n<p>On the dual core below, the numbers also make\u00a0sense, as load avg (across both cores) rises to about 55% total, as\u00a01 core should be at 50% (full loaded) but\u00a0there is still idle time - on the other core I assume. The system only accounts for 0% amazingly.<\/p>\n<p><strong>Dual Core Dell64<\/strong>\u00a0<span style=\"color: #0000ff;\">\u00a0iostat -c 1<\/span><\/p>\n<p>avg-cpu: %user %nice %system %iowait %steal %idle<br \/>\n<strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a055.50<\/strong> 0.00 \u00a0 \u00a0 0.00 0.00 0.00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<strong>44.50<\/strong><\/p>\n<p><strong>Dual Core HP64<\/strong> - seems to verify the single core saturation<\/p>\n<p><span style=\"color: #0000ff;\">\u00a0iostat -c 1<\/span><\/p>\n<p>avg-cpu: %user %nice %system %iowait %steal %idle<br \/>\n<strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a053.23<\/strong> 0.00 1.00 0.00 0.00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <strong>45.77<\/strong><\/p>\n<p><strong>Single Core Celeron32<\/strong> - can never reach 100% as the system requires CPU access also.<\/p>\n<p>avg-cpu: %user %nice %system %iowait %steal %idle<br \/>\n<strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a091.00<\/strong> 0.00 9.00 0.00 0.00 0.00<\/p>\n<p>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?<\/p>\n<p><strong>MPSTAT 1<\/strong><\/p>\n<p><strong>Quad Core<\/strong> no loop\/with loop:\u00a0<span style=\"color: #0000ff;\">mpstat 1<\/span><\/p>\n<p>Average: all <strong>16.67<\/strong> 0.00 3.47 0.94 0.00 0.05 0.00 0.00 0.00 78.87<\/p>\n<p>Average: all <strong>26.93<\/strong> 0.00 0.28 0.13 0.00 0.00 0.00 0.00 0.00 72.65<\/p>\n<p><strong>Single Core Celeron32\u00a0<\/strong>no loop\/with loop:\u00a0<span style=\"color: #0000ff;\">mpstat 1<\/span><\/p>\n<p>Average: all <strong>14.62<\/strong> 0.00 5.65 7.81 0.00 0.00 0.00 0.00 0.00 71.93<\/p>\n<p>Average: all <strong>95.52<\/strong> 0.00 4.48 0.00 0.00 0.00 0.00 0.00 0.00 0.00<\/p>\n<p><strong>Dual Core Dell64\u00a0<\/strong>no loop\/with loop:\u00a0<span style=\"color: #0000ff;\">mpstat 1<\/span><\/p>\n<p>Average: all <strong>8.74<\/strong> 0.00 1.76 0.50 0.00 0.00 0.00 0.00 0.00 89.00<\/p>\n<p>Average: all <strong>57.04<\/strong> 0.00 0.96 0.59 0.00 0.00 0.00 0.00 0.00 41.41<\/p>\n<p><strong>Dual Core HP64<\/strong>\u00a0no loop\/with loop:\u00a0<span style=\"color: #0000ff;\">mpstat 1<\/span><\/p>\n<p>Average: all <strong>4.74<\/strong> 0.00 2.21 0.63 0.00 0.00 0.00 0.00 0.00 92.42<\/p>\n<p>Average: all <strong>52.71<\/strong> 0.00 1.31 0.37 0.00 0.00 0.00 0.00 0.00 45.60<\/p>\n<p>Seems to verify the loop for mpstat also.<\/p>\n<p><strong>SAR 1<\/strong><\/p>\n<p><strong>Quad Core<\/strong> no loop\/with loop: \u00a0<span style=\"color: #0000ff;\">sar 1<\/span><\/p>\n<p>Average: all <strong>3.33<\/strong> 0.00 0.74 0.30 0.00 95.63<\/p>\n<p>Average: all <strong>26.65<\/strong> 0.00 0.50 0.54 0.00 72.30<\/p>\n<p><strong>Dual Core Dell64\u00a0<\/strong>no loop\/with loop:\u00a0<span style=\"color: #0000ff;\">sar 1<\/span><\/p>\n<p>Average: all <strong>8.54<\/strong> 0.00 1.66 0.61 0.00 89.20<\/p>\n<p>Average: all <strong>57.16<\/strong> 0.00 0.68 0.54 0.00 41.62<\/p>\n<p><strong>Dual Core Dell64\u00a0<\/strong>no loop\/with loop:\u00a0<span style=\"color: #0000ff;\">sar 1<\/span><\/p>\n<p>Average: all <strong>5.16<\/strong> 0.00 3.08 0.25 0.00 91.51<\/p>\n<p>Average: all <strong>53.05<\/strong> 0.00 1.35 0.08 0.00 45.53<\/p>\n<p><strong>Single Core Celeron32\u00a0<\/strong>no loop\/with loop: <span style=\"color: #0000ff;\">sar 1<\/span><\/p>\n<p>Average: all <strong>12.89<\/strong> 0.00 7.70 6.86 0.00 72.55<\/p>\n<p>Average: all <strong>96.05<\/strong> 0.00 3.95 0.00 0.00 0.00<\/p>\n<p>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.<\/p>\n<p>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\u00a0NV17GL [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%!<\/p>\n<p><span style=\"color: #0000ff;\">iostat -c 1<\/span><br \/>\n<span style=\"color: #ff0000;\">Linux 3.16.0-38-generic (intelmint) 05\/10\/16 _x86_64_ (2 CPU)<\/span><\/p>\n<p><span style=\"color: #ff0000;\">avg-cpu: %user %nice %system %iowait %steal %idle<\/span><br \/>\n<span style=\"color: #ff0000;\"><strong> 68.51<\/strong> 0.00 5.87 2.84 0.00 22.78<\/span><\/p>\n<p><span style=\"color: #ff0000;\">avg-cpu: %user %nice %system %iowait %steal %idle<\/span><br \/>\n<span style=\"color: #ff0000;\"> 76.50 0.00 5.50 0.00 0.00 18.00<\/span><\/p>\n<p><span style=\"color: #ff0000;\">avg-cpu: %user %nice %system %iowait %steal %idle<\/span><br \/>\n<span style=\"color: #ff0000;\"> 79.00 0.00 4.00 0.00 0.00 17.00<\/span><\/p>\n<p><span style=\"color: #ff0000;\">avg-cpu: %user %nice %system %iowait %steal %idle<\/span><br \/>\n<span style=\"color: #ff0000;\"> 77.00 0.00 5.00 0.00 0.00 18.00<\/span><\/p>\n<p><span style=\"color: #ff0000;\">avg-cpu: %user %nice %system %iowait %steal %idle<\/span><br \/>\n<span style=\"color: #ff0000;\"> 78.28 0.00 5.05 0.00 0.00 16.67<\/span><\/p>\n<p><span style=\"color: #ff0000;\">avg-cpu: %user %nice %system %iowait %steal %idle<\/span><br \/>\n<span style=\"color: #ff0000;\"> 81.09 0.00 3.98 0.00 0.00 14.93<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4302\" class=\"pvc_stats all  \" data-element-id=\"4302\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>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: \u00a0while :; do :; done Here it is running on my localhost core laptop using SysMon's viewer. You can see core 4 rising to <a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/cpu-bound-loop-to-load-1-cpu-core-to-100-to-test-observability-tools\/\" class=\"more-link\">...<span class=\"screen-reader-text\">\u00a0 CPU Bound Loop to Load 1 CPU Core to 100% to Test Observability Tools<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-4302","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"a3_pvc":{"activated":true,"total_views":1,"today_views":0},"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/4302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/comments?post=4302"}],"version-history":[{"count":0,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/4302\/revisions"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/media?parent=4302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/categories?post=4302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/tags?post=4302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}