{"id":8887,"date":"2023-01-17T17:04:16","date_gmt":"2023-01-17T20:04:16","guid":{"rendered":"https:\/\/swiv.com.br\/?p=8887"},"modified":"2023-01-17T17:04:16","modified_gmt":"2023-01-17T20:04:16","slug":"how-the-cached-memory-improve-the-system-performance","status":"publish","type":"post","link":"https:\/\/swiv.com.br\/index.php\/2023\/01\/17\/how-the-cached-memory-improve-the-system-performance\/","title":{"rendered":"How the cached memory improve the system performance"},"content":{"rendered":"\n<p>Este artigo apenas reproduz um teste documentado no Oracle Note &#8220;<strong>Oracle Linux: System Memory Utilization (Doc ID 1514705.1)<\/strong>&#8220;. Como um bom profissional de TI, \u00e9 sempre bom ler a documenta\u00e7\u00e3o e ver se realmente funcionam como dizem que funcionam.<\/p>\n\n\n\n<p>Ambiente de lab:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ cat \/etc\/*release*\nOracle Linux Server release 7.7\nNAME=&quot;Oracle Linux Server&quot;\nVERSION=&quot;7.7&quot;\nID=&quot;ol&quot;\nID_LIKE=&quot;fedora&quot;\nVARIANT=&quot;Server&quot;\nVARIANT_ID=&quot;server&quot;\nVERSION_ID=&quot;7.7&quot;\nPRETTY_NAME=&quot;Oracle Linux Server 7.7&quot;\nANSI_COLOR=&quot;0;31&quot;\nCPE_NAME=&quot;cpe:\/o:oracle:linux:7:7:server&quot;\nHOME_URL=&quot;https:\/\/linux.oracle.com\/&quot;\nBUG_REPORT_URL=&quot;https:\/\/bugzilla.oracle.com\/&quot;\n\nORACLE_BUGZILLA_PRODUCT=&quot;Oracle Linux 7&quot;\nORACLE_BUGZILLA_PRODUCT_VERSION=7.7\nORACLE_SUPPORT_PRODUCT=&quot;Oracle Linux&quot;\nORACLE_SUPPORT_PRODUCT_VERSION=7.7\nRed Hat Enterprise Linux Server release 7.7 (Maipo)\nOracle Linux Server release 7.7\ncpe:\/o:oracle:linux:7:7:server\n<\/pre><\/div>\n\n\n<p>O espa\u00e7o reservado para Cache \u00e9 4.5GB:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ cat \/proc\/meminfo\nMemTotal:       16150712 kB\nMemFree:        10339348 kB\nMemAvailable:   11609716 kB\nBuffers:           18732 kB\nCached:          4556112 kB\n\n...\n\n&#x5B;oracle@oel7 ~]$ free -m\n              total        used        free      shared  buff\/cache   available\nMem:          15772        1163       10093        3101        4515       11333\nSwap:          1231           0        1231\n&#x5B;oracle@oel7 ~]$\n<\/pre><\/div>\n\n\n<p>Criando um arquivo com 500Mb, e analisando que nossa \u00e1rea de cache aumenta esse mesmo espa\u00e7o:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ dd if=\/dev\/zero of=\/tmp\/test.img bs=1M count=500\n500+0 records in\n500+0 records out\n524288000 bytes (524 MB) copied, 1.07127 s, 489 MB\/s\n&#x5B;oracle@oel7 ~]$\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ cat \/proc\/meminfo\nMemTotal:       16150712 kB\nMemFree:         9814132 kB\nMemAvailable:   11596152 kB\nBuffers:           19048 kB\nCached:          5060348 kB\n\n...\n\n&#x5B;oracle@oel7 ~]$ free -m\n              total        used        free      shared  buff\/cache   available\nMem:          15772        1166        9584        3101        5021       11324\nSwap:          1231           0        1231\n&#x5B;oracle@oel7 ~]$\n<\/pre><\/div>\n\n\n<p>Considerando que o arquivo est\u00e1 na \u00e1rea de Cache, vamos simular uma opera\u00e7\u00e3o de I\/O no mesmo, coletando o tempo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ time cat \/tmp\/test.img &gt;\/dev\/null\n\nreal    0m0.162s\nuser    0m0.007s\nsys     0m0.155s\n&#x5B;oracle@oel7 ~]$\n<\/pre><\/div>\n\n\n<p>Realizando o drop da mem\u00f3ria cache, de modo que o arquivo n\u00e3o esteja mais nela:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;root@oel7 ~]# echo 3 &gt; \/proc\/sys\/vm\/drop_caches\n&#x5B;root@oel7 ~]#\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ free -m\n              total        used        free      shared  buff\/cache   available\nMem:          15772        1159       12970        1146        1641       13301\nSwap:          1231           0        1231\n&#x5B;oracle@oel7 ~]$\n<\/pre><\/div>\n\n\n<p>Refazendo o teste e percebendo realmente a diferen\u00e7a de performance:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;oracle@oel7 ~]$ time cat \/tmp\/test.img &gt;\/dev\/null\n\nreal    0m4.977s\nuser    0m0.008s\nsys     0m0.379s\n&#x5B;oracle@oel7 ~]$\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Este artigo apenas reproduz um teste documentado no Oracle Note &#8220;Oracle Linux: System Memory Utilization (Doc ID 1514705.1)&#8220;. Como um bom profissional de TI, \u00e9 sempre bom ler a documenta\u00e7\u00e3o e ver se realmente funcionam como dizem que funcionam. Ambiente de lab: O espa\u00e7o reservado para Cache \u00e9 4.5GB: Criando um arquivo com 500Mb, e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-8887","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/8887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=8887"}],"version-history":[{"count":0,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/posts\/8887\/revisions"}],"wp:attachment":[{"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=8887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=8887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swiv.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=8887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}