{"id":103353,"date":"2020-05-21T05:25:07","date_gmt":"2020-05-20T21:25:07","guid":{"rendered":"http:\/\/4563.org\/?p=103353"},"modified":"2020-05-21T05:25:07","modified_gmt":"2020-05-20T21:25:07","slug":"%e8%af%91-%ef%bd%83%e7%a8%8b%e5%ba%8f%e5%91%98%e8%af%a5%e7%9f%a5%e9%81%93%e7%9a%84%e5%86%85%e5%ad%98%e7%9f%a5%e8%af%86-4","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=103353","title":{"rendered":"[\u8bd1] \uff23\u7a0b\u5e8f\u5458\u8be5\u77e5\u9053\u7684\u5185\u5b58\u77e5\u8bc6 (4)"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [\u8bd1] \uff23\u7a0b\u5e8f\u5458\u8be5\u77e5\u9053\u7684\u5185\u5b58\u77e5\u8bc6 (4)               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : felix021 <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7cfb\u5217\u66f4\u65b0\uff1a<\/p>\n<ul>\n<li>\uff23\u7a0b\u5e8f\u5458\u8be5\u77e5\u9053\u7684\u5185\u5b58\u77e5\u8bc6 (1)<\/li>\n<li>\uff23\u7a0b\u5e8f\u5458\u8be5\u77e5\u9053\u7684\u5185\u5b58\u77e5\u8bc6 (2)<\/li>\n<li>\uff23\u7a0b\u5e8f\u5458\u8be5\u77e5\u9053\u7684\u5185\u5b58\u77e5\u8bc6 (3)<\/li>\n<\/ul>\n<p>\u8fd9\u662f\u672c\u7cfb\u5217\u7684\u7b2c 4 \u7bc7\uff0c\u4e5f\u662f\u6700\u540e\u4e00\u7bc7\uff0c\u542b\u6cea\u586b\u5b8c\u8fd9\u4e2a\u5751\u4e0d\u5bb9\u6613\uff0c\u611f\u8c22\u9605\u8bfb~<\/p>\n<p>\u8fd9\u4e2a\u7cfb\u5217\u592a\u5e72\u4e86\uff0c\u9605\u8bfb\u91cf\u4e00\u7bc7\u6bd4\u4e00\u7bc7\u5c11\uff0c\u4f46\u6211\u4ecd\u7136\u8ba4\u4e3a\u8fd9\u4e2a\u7cfb\u5217\u975e\u5e38\u6709\u4ef7\u503c\uff0c\u5728\u7ffb\u8bd1\u7684\u8fc7\u7a0b\u4e2d\u6211\u4e5f\u501f\u673a\u8fdb\u884c\u7cfb\u7edf\u6027\u7684\u68b3\u7406\u3001\u5e76\u5b66\u4e60\u4e86\u5f88\u591a\u65b0\u77e5\u8bc6\uff0c\u6536\u83b7\u6ee1\u6ee1\u3002\u5e0c\u671b\u4f60\u4e5f\u80fd\u6709\u6536\u83b7\uff08\u4f46\u80af\u5b9a\u6ca1\u6211\u591a\uff09\u3002<\/p>\n<p>\u90a3\uff0c\u5f00\u59cb\u5427\u3002<\/p>\n<h1>\u7406\u89e3\u5185\u5b58\u6d88\u8017<\/h1>\n<p> <\/p>\n<p>\u5de5\u5177\u7bb1\uff1a<\/p>\n<ul>\n<li>vmtouch[2] &#8211;\u00a0portable virtual memory toucher<\/li>\n<\/ul>\n<p>\uff08\u8bd1\u6ce8\uff1avmtouch \u8fd9\u4e2a\u5de5\u5177\u7528\u6765\u8bca\u65ad\u548c\u63a7\u5236\u7cfb\u7edf\u5bf9\u6587\u4ef6\u7cfb\u7edf\u7684\u7f13\u5b58\uff0c\u4f8b\u5982\u67e5\u770b\u67d0\u4e2a\u6587\u4ef6\u88ab\u7f13\u5b58\u4e86\u591a\u5c11\u9875\uff0c\u6e05\u7a7a\u67d0\u4e2a\u6587\u4ef6\u7684\u7f13\u5b58\u9875\uff0c\u6216\u5c06\u67d0\u4e2a\u6587\u4ef6\u7684\u9875\u9762\u9501\u5b9a\u5728\u5185\u5b58\u4e2d\uff1b\u57fa\u4e8e\u8fd9\u4e9b\u529f\u80fd\u53ef\u4ee5\u5b9e\u73b0\u5f88\u591a\u6709\u610f\u601d\u7684\u5e94\u7528\uff1b\u8be6\u60c5\u53c2\u8003\u8be5\u5de5\u5177\u7684\u6587\u6863\u3002\uff09<\/p>\n<p>\u7136\u800c\u5171\u4eab\u5185\u5b58\u7684\u6982\u5ff5\u5bfc\u81f4\u4f20\u7edf\u65b9\u6848 \u2014\u2014 \u6d4b\u91cf\u5bf9\u5185\u5b58\u7684\u5360\u7528 \u2014\u2014 \u53d8\u5f97\u65e0\u6548\u4e86\uff0c\u56e0\u4e3a\u6ca1\u6709\u4e00\u4e2a\u516c\u6b63\u7684\u65b9\u6cd5\u53ef\u4ee5\u6d4b\u91cf\u4f60\u8fdb\u7a0b\u7684\u72ec\u5360\u7a7a\u95f4\u3002\u8fd9\u4f1a\u5f15\u8d77\u56f0\u60d1\u751a\u81f3\u6050\u60e7\uff0c\u53ef\u80fd\u662f\u4e24\u65b9\u9762\u7684\uff1a<\/p>\n<blockquote>\n<p>\u7528\u4e0a\u4e86\u57fa\u4e8e mmap\u00a0\u7684 I\/O \u64cd\u4f5c\u540e\uff0c\u6211\u4eec\u7684\u5e94\u7528\u73b0\u5728\u51e0\u4e4e\u4e0d\u5360\u7528\u5185\u5b58.<\/p>\n<p>\u2014\u00a0CorporateGuy<\/p>\n<p>\u6c42\u6551\uff01\u6211\u8fd9\u5199\u5165\u5171\u4eab\u5185\u5b58\u7684\u8fdb\u7a0b\u6709\u4e25\u91cd\u7684\u5185\u5b58\u6cc4\u6f0f\uff01\uff01\uff01<\/p>\n<p>\u2014\u00a0HeavyLifter666<\/p>\n<\/blockquote>\n<p>\u9875\u9762\u6709\u4e24\u79cd\u72b6\u6001\uff1a\u6e05\u6d01(clean)\u9875\u548c\u810f(dirty)\u9875\u3002\u533a\u522b\u662f\uff0c\u810f\u9875\u5728\u88ab\u56de\u6536\u4e4b\u524d\u9700\u8981\u88ab\u5199\u56de\u5230\u6301\u4e45\u5b58\u50a8\u4e2d\uff08\u8bd1\u6ce8\uff1a\u5199\u56de\u6587\u4ef6\u5b9e\u9645\u5b58\u653e\u7684\u5730\u65b9\uff09\u3002MADV_FREE \u8fd9\u4e2a\u5efa\u8bae\u901a\u8fc7\u5c06\u810f\u6807\u5fd7\u4f4d\u6e05\u96f6\u8fd9\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0\u66f4\u8f7b\u91cf\u7684\u5185\u5b58\u91ca\u653e\uff0c\u800c\u4e0d\u662f\u4fee\u6539\u6574\u4e2a\u9875\u8868\u9879\uff08\u8bd1\u6ce8\uff1apage table entry\uff0c\u5e38\u7f29\u5199\u4e3a PTE\uff0c\u8bb0\u5f55\u9875\u9762\u7684\u7269\u7406\u9875\u53f7\u53ca\u82e5\u5e72\u6807\u5fd7\u4f4d\uff0c\u5982\u80fd\u5426\u8bfb\u5199\u3001\u662f\u5426\u810f\u9875\u3001\u662f\u5426\u5728\u5185\u5b58\u4e2d\u7b49\uff09\u3002\u6b64\u5916\uff0c\u6bcf\u4e00\u9875\u90fd\u53ef\u80fd\u662f\u79c1\u6709\u7684\u6216\u5171\u4eab\u7684\uff0c\u8fd9\u6b63\u662f\u5bfc\u81f4\u56f0\u60d1\u7684\u6e90\u5934\u3002<\/p>\n<p>\u524d\u9762\u5f15\u7528\u7684\u4e24\u4e2a\u90fd\u662f\uff08\u90e8\u5206\uff09\u771f\u5b9e\u7684\uff0c\u53d6\u51b3\u4e8e\u89c6\u89d2\u3002\u5728\u7cfb\u7edf\u7f13\u51b2\u533a\u7684\u9875\u9762\u9700\u8981\u8ba1\u5165\u8fdb\u7a0b\u7684\u5185\u5b58\u6d88\u8017\u91cc\u5417\uff1f\u5982\u679c\u8fdb\u7a0b\u4fee\u6539\u4e86\u7f13\u51b2\u533a\u91cc\u90a3\u4e9b\u6620\u5c04\u6587\u4ef6\u7684\u90a3\u4e9b\u9875\u9762\u5462\uff1f\u5728\u8fd9\u6df7\u4e71\u4e2d\u53ef\u4ee5\u6574\u51fa\u70b9\u6709\u7528\u7684\u4e1c\u897f\u4e48\uff1f<\/p>\n<p>\u5047\u8bbe\u6709\u4e00\u4e2a\u8fdb\u7a0b\uff0c<strong>\u7d22\u4f26\u4e4b\u773c\uff08 the_eye \uff09<\/strong> \u4f1a\u5199\u5165\u5bf9**\u9b54\u90fd\uff08 mordor \uff09**\u7684\u5171\u4eab\u6620\u5c04\uff08\u8bd1\u6ce8\uff1a\u6307\u73af\u738b\u7684\u6897\uff09\u3002\u5199\u5165\u5171\u4eab\u5185\u5b58\u4e0d\u8ba1\u5165 RSS \uff08 resident set size\uff0c\u5e38\u9a7b\u5185\u5b58\u96c6\uff09\u7684\uff0c\u5bf9\u5427\uff1f<\/p>\n<pre><code>$ ps -p $$ -o pid,rss   PID  RSS 17906  1574944 # &lt;-- \u4ec0\u4e48\u9b3c? \u5360\u7528 1.5GB \uff1f <\/code><\/pre>\n<p>\uff08\u8bd1\u6ce8\uff1a$$ \u662f bash \u53d8\u91cf\uff0c\u4fdd\u5b58\u4e86\u5728\u6267\u884c\u5f53\u524d script \u7684 shell \u7684 PID \uff1b\u8fd9\u91cc\u5e94\u8be5\u662f\u7528\u6765\u6307\u4ee3 the_eye \u7684 PID \uff09<\/p>\n<p>\u5443\uff0c\u8ba9\u6211\u4eec\u56de\u5230\u5c0f\u9ed1\u677f\u3002<\/p>\n<h2>PSS \uff08 Proportional Set Size \uff09<\/h2>\n<p>PSS \uff08\u8bd1\u6ce8\uff1aProportional \u610f\u601d\u662f \u201c\u6bd4\u4f8b\u7684\u201d\uff09 \u8ba1\u5165\u4e86\u79c1\u6709\u6620\u5c04\uff0c\u4ee5\u53ca\u6309\u6bd4\u4f8b\u8ba1\u5165\u5171\u4eab\u6620\u5c04\u3002\u8fd9\u662f\u6211\u4eec\u80fd\u5f97\u5230\u7684\u6700\u5408\u7406\u7684\u5185\u5b58\u8ba1\u7b97\u65b9\u5f0f\u4e86\u3002\u5173\u4e8e\u201c\u6bd4\u4f8b\u201d\uff0c\u662f\u6307\u5c06\u5171\u4eab\u5185\u5b58\u9664\u4ee5\u5171\u4eab\u5b83\u7684\u8fdb\u7a0b\u6570\u91cf\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u6709\u4e2a\u5e94\u7528\u9700\u8981\u8bfb\u5199\u67d0\u4e2a\u5171\u4eab\u5185\u5b58\u6620\u5c04\uff1a<\/p>\n<pre><code>$ cat \/proc\/$$\/maps 00400000-00410000         r-xp 0000 08:03 1442958 \/tmp\/the_eye 00bda000-01a3a000         rw-p 0000 00:00 0       [heap] 7efd09d68000-7f0509d68000 rw-s 0000 08:03 4065561 \/tmp\/mordor.map 7f0509f69000-7f050a108000 r-xp 0000 08:03 2490410 libc-2.19.so 7fffdc9df000-7fffdca00000 rw-p 0000 00:00 0       [stack] ... \u4ee5\u4e0b\u622a\u65ad ... <\/code><\/pre>\n<p>\uff08\u8bd1\u6ce8\uff1acat \/proc\/$PID\/maps \u662f\u4ece\u5185\u6838\u4e2d\u8bfb\u53d6\u8fdb\u7a0b\u7684\u6240\u6709\u5185\u5b58\u6620\u5c04\uff09<\/p>\n<p>\u8fd9\u662f\u4e2a\u88ab\u7b80\u5316\u5e76\u622a\u65ad\u4e86\u7684\u6620\u5c04\uff0c\u7b2c\u4e00\u5217\u662f\u5730\u5740\u8303\u56f4\uff0c\u7b2c\u4e8c\u5217\u662f\u6743\u9650\u4fe1\u606f\uff0c\u5176\u4e2d r \u8868\u793a\u53ef\u8bfb\uff0cw \u8868\u793a\u53ef\u5199\uff0cx \u8868\u793a\u53ef\u6267\u884c \u2014\u2014\u00a0\u8fd9\u90fd\u662f\u8001\u77e5\u8bc6\u70b9\u4e86 \u2014\u2014 \u7136\u540e s \u8868\u793a\u5171\u4eab\uff0cp \u8868\u793a\u79c1\u6709\u3002\u7136\u540e\u662f\u6620\u5c04\u6587\u4ef6\u7684\u504f\u79fb\u91cf\uff0c\u8bbe\u5907\u53f7\uff08 OS \u5206\u914d\u7684\uff09\uff0cinode \u53f7\uff08\u6587\u4ef6\u7cfb\u7edf\u4e0a\u7684\uff09\uff0c\u4ee5\u53ca\u6700\u540e\u662f\u6587\u4ef6\u7684\u8def\u5f84\u540d\u3002\u5177\u4f53\u53c2\u89c1\u8fd9\u4e2a\u6587\u6863[3]\uff08\u8bd1\u6ce8\uff1akernel.org \u5bf9 \/proc \u6587\u4ef6\u7cfb\u7edf\u7684\u8bf4\u660e\u6587\u6863\uff09\uff0c\u8d85\u7ea7\u8be6\u7ec6\u3002<\/p>\n<p>\u6211\u5f97\u627f\u8ba4\u6211\u5220\u6389\u4e86\u4e00\u4e9b\u8f93\u51fa\u4e2d\u4e00\u4e9b\u4e0d\u592a\u6709\u610f\u601d\u7684\u4fe1\u606f\u3002\u5982\u679c\u4f60\u5bf9\u88ab\u79c1\u6709\u6620\u5c04\u7684\u5e93\u611f\u5174\u8da3\u7684\u8bdd\u53ef\u4ee5\u8bfb\u4e00\u4e0b FAQ-\u4e3a\u4ec0\u4e48\u201cstrict overcommit\u201d\u662f\u4e2a\u8822\u4e3b\u610f[4]\uff08\u8bd1\u6ce8\uff1a\u6839\u636e\u8fd9\u4e2a FAQ\uff0cstrict overcommit \u5e94\u8be5\u662f\u6307\u5141\u8bb8 overcommmit \u3001\u4f46\u8981\u4e3a\u7533\u8bf7\u7684\u6bcf\u4e00\u4e2a\u865a\u62df\u9875\u5206\u914d\u4e00\u4e2a\u771f\u5b9e\u9875\uff0c\u4e0d\u7ba1\u662f\u7528\u7269\u7406\u9875\u8fd8\u662f swap\uff0c\u786e\u5b9e\u542c\u8d77\u6765\u5f88\u8822\u2026\u2026\uff09\u3002\u4e0d\u8fc7\u8fd9\u91cc\u6211\u4eec\u611f\u5174\u8da3\u7684\u662f\u9b54\u90fd\uff08 mordor \uff09\u8fd9\u4e2a\u6620\u5c04\uff1a<\/p>\n<pre><code>$ grep -A12 mordor.map \/proc\/$$\/smaps Size:           33554432 kB Rss:             1557632 kB Pss:             1557632 kB Shared_Clean:          0 kB Shared_Dirty:          0 kB Private_Clean:   1557632 kB Private_Dirty:         0 kB Referenced:      1557632 kB Anonymous:             0 kB AnonHugePages:         0 kB Swap:                  0 kB KernelPageSize:        4 kB MMUPageSize:           4 kB Locked:                0 kB VmFlags: rd wr sh mr mw me ms sd <\/code><\/pre>\n<p>\u8bd1\u6ce8\uff1a\u8fd9\u4e2a<strong>\u6587\u4ef6\u5927\u5c0f 32GB<\/strong>\uff0c\u5df2\u52a0\u8f7d\u4e86 1521MB \u5230\u5185\u5b58\u4e2d\uff0c\u56e0\u4e3a\u53ea\u6709\u8fd9\u4e00\u4e2a\u8fdb\u7a0b\u6620\u5c04\u4e86\u5b83\uff0c\u6240\u4ee5\u5728\u8fd9\u4e2a\u8fdb\u7a0b\u7684 PSS \u4e2d\u5360\u6bd4\u662f 100%\uff0c\u4e5f\u662f 1521MB \u3002<\/p>\n<p>\u5728\u5171\u4eab\u6620\u5c04\u91cc\u7684\u79c1\u6709\u9875\u9762 \u2014\u2014 \u641e\u5f97\u6211\u50cf\u5deb\u5e08\u4e00\u6837\uff1f\u5728 Linux \u4e0a\uff0c\u5373\u4f7f\u5171\u4eab\u5185\u5b58\u4e5f\u4f1a\u88ab\u8ba4\u4e3a\u662f\u79c1\u6709\u7684\uff0c\u9664\u975e\u5b83\u771f\u7684\u88ab\u5171\u4eab\u4e86\uff08\u8bd1\u6ce8\uff1a\u4e0d\u6b62\u4e00\u4e2a\u8fdb\u7a0b\u521b\u5efa\u5171\u4eab\u6620\u5c04\uff09\u3002\u8ba9\u6211\u4eec\u770b\u770b\u5b83\u662f\u5426\u5728\u7cfb\u7edf\u7f13\u51b2\u533a\u91cc\uff1a<\/p>\n<pre><code>#\u00a0\u597d\u50cf\u5f00\u5934\u7684\u90a3\u4e00\u5757\u5728\u5185\u5b58\u4e2d... $ vmtouch -m 64G -v mordor.map [OOo                    ] 389440\/8388608             Files: 1      Directories: 0   Resident Pages: 389440\/8388608  1G\/32G  4.64%          Elapsed: 0.27624 seconds  # \u5c06\u5b83\u5168\u90fd\u8f7d\u5165\u5230 Cache! $ cat mordor.map &gt; \/dev\/null $ vmtouch -m 64G -v mordor.map [ooooooooo      oooOOOOO] 2919606\/8388608             Files: 1      Directories: 0   Resident Pages: 2919606\/8388608  11G\/32G  34.8%          Elapsed: 0.59845 seconds <\/code><\/pre>\n<p>\u8bd1\u6ce8\uff1a<\/p>\n<ol>\n<li>\n<p>\u201c-m 64G\u201d\u00a0\u8868\u793a\u5141\u8bb8 vmtouch \u5c06\u5c0f\u4e8e 64G \u7684\u6587\u4ef6\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff0c\u5e94\u5f53\u662f\u7528\u4e8e\u9700\u8981\u52a0\u8f7d\u4e00\u4e2a\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u3001\u4f46\u6392\u9664\u5176\u4e2d\u8fc7\u5927\u7684\u6587\u4ef6\uff0c\u4f3c\u4e4e\u4e0d\u9002\u7528\u4e8e\u8fd9\u91cc\uff1b\u81f3\u5c11\u5ffd\u7565\u8fd9\u4e2a\u53c2\u6570\u4e0d\u5f71\u54cd\u9605\u8bfb<\/p>\n<\/li>\n<li>\n<p>o \u8868\u793a\u8fd9\u4e00\u5757\u90e8\u5206\u88ab\u52a0\u8f7d\uff0cO \u8868\u793a\u5168\u90e8\u88ab\u52a0\u8f7d\u3002\u56e0\u4e3a\u7269\u7406\u5185\u5b58\u6709\u9650\uff0c\u867d\u7136\u5168\u91cf\u8bfb\u53d6\u4e86\u6587\u4ef6\uff0c\u4f46\u53ea\u6709\u90e8\u5206\u5185\u5bb9\u88ab\u7f13\u5b58<\/p>\n<\/li>\n<\/ol>\n<p>\u55ec\uff0c\u53ea\u662f\u7b80\u5355\u5730\u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6\u5c31\u4f1a\u628a\u5b83\u7f13\u5b58\u8d77\u6765\uff1f\u5148\u4e0d\u7ba1\u8fd9\uff0c\u6211\u4eec\u7684\u8fdb\u7a0b\u5462\uff1f<\/p>\n<pre><code>$ ps\u00a0-p\u00a0$$\u00a0-o\u00a0pid,rss   PID   RSS 17906 286584 # &lt;-- \u7b49\u4e86\u8db3\u8db3\u4e00\u5206\u949f <\/code><\/pre>\n<p>\u5e38\u89c1\u7684\u8bef\u89e3\u662f\uff0c\u6620\u5c04\u6587\u4ef6\u4f1a\u6d88\u8017\u5185\u5b58\uff0c\u800c\u901a\u8fc7\u6587\u4ef6 API \u8bfb\u53d6\u4e0d\u4f1a\u3002\u5b9e\u9645\u4e0a\uff0c\u65e0\u8bba\u54ea\u4e00\u79cd\u65b9\u5f0f\uff0c\u5305\u542b\u6587\u4ef6\u5185\u5bb9\u7684\u9875\u9762\u90fd\u4f1a\u88ab\u653e\u8fdb\u7cfb\u7edf\u7f13\u51b2\u533a\u3002\u4f46\u8fd8\u6709\u4e2a\u5c0f\u7684\u533a\u522b\u662f\uff0c\u4f7f\u7528 mmap \u7684\u65b9\u5f0f\u9700\u8981\u5728\u8fdb\u7a0b\u7684\u9875\u8868\u4e2d\u521b\u5efa\u5bf9\u5e94\u7684\u9875\u8868\u9879\uff08 PTE \uff09\uff0c\u800c\u8fd9\u4e9b\u5305\u542b\u6587\u4ef6\u5185\u5bb9\u7684\u9875\u9762\u662f\u53ef\u4ee5\u88ab\u5171\u4eab\u7684\u3002\u6709\u8da3\u7684\u662f\uff0c\u6211\u4eec\u8fd9\u4e2a\u8fdb\u7a0b\u7684 RSS \u7f29\u5c0f\u4e86\uff0c\u56e0\u4e3a\u7cfb\u7edf\u00a0<em>\u9700\u8981<\/em> \u8fdb\u7a0b\u7684\u9875\u9762\u4e86\uff08\u8bd1\u6ce8\uff1a\u56e0\u4e3a mordor \u592a\u5927\uff0c\u53ef\u7528\u7269\u7406\u5185\u5b58\u9875\u4e0d\u591f\uff0c\u7cfb\u7edf\u5c06 the_eye \u7684\u90e8\u5206\u9875\u9762 swap \u4e86\uff1b\u6240\u4ee5\u524d\u8ff0\u547d\u4ee4\u624d\u4f1a\u9700\u8981\u7b49\u4e00\u5206\u949f\uff0c\u56e0\u4e3a\u6d89\u53ca\u5230\u78c1\u76d8 IO \uff09\u3002<\/p>\n<h2>\u6709\u65f6\u6211\u4eec\u7684\u6240\u6709\u60f3\u6cd5\u90fd\u662f\u9519\u7684<\/h2>\n<p>\u6620\u5c04\u6587\u4ef6\u7684\u5185\u5b58\u603b\u662f\u53ef\u88ab\u56de\u6536\u7684\uff0c\u533a\u522b\u53ea\u5728\u4e8e\u8be5\u9875\u662f\u5426\u810f\u9875 \u2014\u2014 \u810f\u9875\u5728\u56de\u6536\u524d\u9700\u8981\u88ab\u6e05\u7406\uff08\u8bd1\u6ce8\uff1a\u5199\u56de\u5e95\u5c42\u5b58\u50a8\uff09\u3002\u6240\u4ee5\u5f53\u4f60\u5728 top \u547d\u4ee4\u53d1\u73b0\u6709\u4e00\u4e2a\u8fdb\u7a0b\u5360\u7528\u4e86\u5927\u91cf\u5185\u5b58\u65f6\u662f\u5426\u9700\u8981\u6050\u614c\uff1f\u5f53\u8fd9\u4e2a\u8fdb\u7a0b\u6709\u5f88\u591a\u533f\u540d\u7684\u810f\u9875\u7684\u65f6\u5019\u624d\u9700\u8981\u6050\u614c\u2014\u2014\u56e0\u4e3a\u8fd9\u4e9b\u9875\u9762\u65e0\u6cd5\u88ab\u56de\u6536\u3002\u5982\u679c\u4f60\u53d1\u73b0\u6709\u4e2a\u533f\u540d\u6620\u5c04\u6bb5\u5728\u589e\u957f\uff0c\u4f60\u53ef\u80fd\u5c31\u6709\u9ebb\u70e6\u4e86\uff08\u800c\u4e14\u662f\u53cc\u500d\u7684\u9ebb\u70e6\uff09\u3002\u4f46\u662f\u4e0d\u8981\u76f2\u76ee\u76f8\u4fe1 RSS \u751a\u81f3 PSS \u3002<\/p>\n<p>\u53e6\u4e00\u4e2a\u5e38\u89c1\u9519\u8bef\u662f\u8ba4\u4e3a\u8fdb\u7a0b\u7684\u865a\u62df\u5185\u5b58\u548c\u5b9e\u9645\u6d88\u8017\u5185\u5b58\u4e4b\u95f4\u603b\u6709\u67d0\u79cd\u5173\u7cfb\uff0c\u751a\u81f3\u8ba4\u4e3a\u6240\u6709\u5185\u5b58\u6620\u5c04\u90fd\u4e00\u6837\u3002\u4efb\u4f55\u53ef\u56de\u6536\u7684\u5185\u5b58\uff0c\u5b9e\u9645\u4e0a\u90fd\u53ef\u4ee5\u8ba4\u4e3a\u662f\u7a7a\u95f2\u7684\u3002\u7b80\u800c\u8a00\u4e4b\uff0c\u5b83\u4e0d\u4f1a\u5bfc\u81f4\u4f60\u4e0b\u6b21\u5185\u5b58\u5206\u914d\u5931\u8d25\uff0c\u4f46_\u53ef\u80fd_\u4f1a\u589e\u52a0\u5206\u914d\u7684\u5ef6\u8fdf \u2014\u2014\u00a0\u8fd9\u70b9\u6211\u4f1a\u89e3\u91ca\uff1a<\/p>\n<p>\u5185\u5b58\u7ba1\u7406\u5668\u9700\u8981\u82b1\u5f88\u5927\u529f\u592b\u6765\u51b3\u5b9a\u54ea\u4e9b\u4e1c\u897f\u9700\u8981\u4fdd\u5b58\u5728\u7269\u7406\u5185\u5b58\u91cc\u3002\u5b83\u53ef\u80fd\u4f1a\u51b3\u5b9a\u5c06\u8fdb\u7a0b\u5185\u5b58\u4e2d\u7684\u4e00\u90e8\u5206\u8c03\u5230 swap\uff0c\u4ee5\u4fbf\u7ed9\u7cfb\u7edf\u7f13\u5b58\u817e\u51fa\u7a7a\u95f4\uff0c\u56e0\u6b64\u8be5\u8fdb\u7a0b\u4e0b\u6b21\u8bbf\u95ee\u8fd9\u4e00\u5757\u65f6\u9700\u8981\u518d\u5c06\u8fd9\u4e9b\u9875\u9762\u8c03\u56de\u5230\u7269\u7406\u5185\u5b58\u4e2d\u3002\u5e78\u8fd0\u7684\u662f\u8fd9\u901a\u5e38\u662f\u53ef\u4ee5\u914d\u7f6e\u7684\u3002\u4f8b\u5982\uff0cLinux \u6709\u4e00\u4e2a\u53eb\u505a swappiness[5] \u7684\u9009\u9879\uff0c\u7528\u6765\u6307\u5bfc\u5185\u6838\u4f55\u65f6\u5f00\u59cb\u5c06\u533f\u540d\u6620\u5c04\u7684\u5185\u5b58\u9875\u8c03\u51fa\u5230 swap \u3002\u5f53\u5b83\u53d6\u503c\u4e3a 0 \u662f\u8868\u793a\u201c\u76f4\u5230\u7edd\u5bf9\u7edd\u5bf9\u6709\u5fc5\u8981\u7684\u65f6\u5019\u201d\uff08\u8bd1\u6ce8\uff1a\u53d6\u503c[0, 100]\uff0c\u503c\u8d8a\u4f4e\uff0c\u7cfb\u7edf\u8d8a\u503e\u5411\u4e8e\u5148\u6e05\u7406\u7cfb\u7edf\u7f13\u51b2\u533a\u7684\u9875\u9762\uff09\u3002<\/p>\n<h1>\u7ec8\u7ae0\uff0c\u4e00\u52b3\u6c38\u9038\u5730<\/h1>\n<p> <\/p>\n<p>\u5982\u679c\u4f60\u770b\u5230\u8fd9\u91cc\uff0c\u5411\u4f60\u81f4\u656c\uff01\u6211\u5728\u5de5\u4f5c\u4e4b\u4f59\u5199\u7684\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5e0c\u671b\u80fd\u7528\u4e00\u79cd\u66f4\u65b9\u4fbf\u7684\u65b9\u5f0f\uff0c\u4e0d\u4ec5\u80fd\u89e3\u91ca\u8fd9\u4e9b\u8bf4\u8fc7\u4e0a\u5343\u904d\u7684\u6982\u5ff5\uff0c\u8fd8\u80fd\u5e2e\u6211\u6574\u7406\u8fd9\u4e9b\u601d\u7ef4\uff0c\u4ee5\u53ca\u5e2e\u52a9\u5176\u4ed6\u4eba\u3002\u6211\u82b1\u4e86\u6bd4\u9884\u671f\u66f4\u957f\u7684\u65f6\u95f4\u3002\u8fdc\u8d85\u9884\u671f\u3002<\/p>\n<p>\u6211\u5bf9\u6587\u7ae0\u7684\u4f5c\u8005\u4eec\u53ea\u6709\u65e0\u5c3d\u7684\u656c\u610f\uff0c\u56e0\u4e3a\u5199\u4f5c\u771f\u662f\u4e2a\u5197\u957f\u4e4f\u5473\u3001\u4ee4\u4eba\u5934\u79c3\u7684\u8fc7\u7a0b\uff0c\u9700\u8981\u6c38\u65e0\u6b62\u5883\u7684\u4fee\u6539\u548c\u91cd\u5199\u3002Jeff Atwood \uff08\u8bd1\u6ce8\uff1astack overflow \u7684\u521b\u59cb\u4eba\uff09\u66fe\u8bf4\u8fc7\uff0c\u6700\u597d\u7684\u5b66\u7f16\u7a0b\u4e66\u7c4d\u662f\u6559\u4f60\u76d6\u623f\u5b50\u7684\u90a3\u672c\u3002\u6211\u4e0d\u8bb0\u5f97\u5728\u54ea\u513f\u4e86\uff0c\u6240\u4ee5\u65e0\u6cd5\u5f15\u7528\u5b83\u3002\u6211\u53ea\u80fd\u8bf4\uff0c\u7b2c\u4e8c\u597d\u7684\u662f\u6559\u4f60\u5199\u4f5c\u7684\u90a3\u672c\u3002\u8bf4\u5230\u5e95\uff0c\u7f16\u7a0b\u672c\u8d28\u4e0a\u5c31\u662f\u5199\u6545\u4e8b\uff0c\u7b80\u660e\u627c\u8981\u3002<\/p>\n<p>EDIT\uff1a\u6211\u4fee\u6b63\u4e86\u5173\u4e8e alloca() \u548c \u5c06 sizeof(char) \u8bef\u5199\u4e3a sizeof(char*) \u7684\u9519\u8bef\uff0c\u591a\u4e8f\u4e86 immibis \u548c BonzaiThePenguin \u3002\u611f\u8c22 sWvich \u6307\u51fa\u5728 slab + sizeof(struct slab)\u00a0\u91cc\u6f0f\u4e86\u7684\u7c7b\u578b\u8f6c\u6362\u3002\u663e\u7136\u6211\u5e94\u8be5\u7528\u9759\u6001\u5206\u6790\u8dd1\u4e00\u4e0b\u8fd9\u7bc7\u6587\u7ae0\uff0c\u4f46\u5e76\u6ca1\u6709 \u2014\u2014\u00a0\u6da8\u7ecf\u9a8c\u4e86\u3002<\/p>\n<p>\u5f00\u653e\u95ee\u9898 \u2014\u2014 \u6709\u6ca1\u6709\u6bd4 Markdown \u4ee3\u7801\u5757\u66f4\u597d\u7684\u5b9e\u73b0\uff1f\u6211\u5e0c\u671b\u80fd\u5c55\u793a\u5e26\u6ce8\u91ca\u7684\u6458\u5f55\uff0c\u5e76\u4e14\u80fd\u4e0b\u8f7d\u6574\u4e2a\u4ee3\u7801\u5757\u3002<\/p>\n<p><em>\u5199\u4e8e 2015 \u5e74 2 \u6708 20 \u65e5\u3002<\/em><\/p>\n<p>\u8bfb\u5230\u8fd9\u91cc\u90fd\u662f\u771f\u7231\uff0c\u559c\u6b22\u7684\u8bdd\u8bf7\u7559\u8a00\u652f\u6301\uff0c\u8ba9\u66f4\u591a\u4eba\u770b\u5230\uff0c\u611f\u8c22~<\/p>\n<p>\u7167\u4f8b\u518d\u8d34\u4e0b\u4e4b\u524d\u63a8\u9001\u7684\u51e0\u7bc7\u6587\u7ae0\uff1a<\/p>\n<ul>\n<li>\n<p>\u300a\u8e29\u5751\u8bb0\uff1ago \u670d\u52a1\u5185\u5b58\u66b4\u6da8\u300b<\/p>\n<\/li>\n<li>\n<p>\u300aTCP\uff1a\u5b66\u5f97\u8d8a\u591a\u8d8a\u4e0d\u61c2\u300b<\/p>\n<\/li>\n<li>\n<p>\u300aTCP#2: \u897f\u53a2\u8bb0\u548c\u897f\u53a2\u8ba1\u5212\u300b<\/p>\n<\/li>\n<li>\n<p>\u300aUTF-8\uff1a\u4e00\u4e9b\u597d\u50cf\u6ca1\u4ec0\u4e48\u7528\u7684\u51b7\u77e5\u8bc6\u300b<\/p>\n<\/li>\n<li>\n<p>\u300a\u5173\u4e8e RSA \u7684\u4e00\u4e9b\u8da3\u4e8b\u300b<\/p>\n<\/li>\n<li>\n<p>\u300a\u7a0b\u5e8f\u5458\u9762\u8bd5\u6307\u5317\uff1a\u9762\u8bd5\u5b98\u89c6\u89d2\u300b<\/p>\n<\/li>\n<\/ul>\n<h2>\u6b22\u8fce\u5173\u6ce8<\/h2>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/20200526_5eccd5d579fb3.png\" alt=\"[\u8bd1] \uff23\u7a0b\u5e8f\u5458\u8be5\u77e5\u9053\u7684\u5185\u5b58\u77e5\u8bc6 (4)\" \/><\/p>\n<pre><code>   \u2584\u2584\u2584\u2584\u2584\u2584\u2584   \u2584      \u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2584\u2584      \u2588 \u2584\u2584\u2584 \u2588 \u2584\u2580 \u2584 \u2580\u2588\u2588\u2584 \u2580\u2588\u2584 \u2588 \u2584\u2584\u2584 \u2588      \u2588 \u2588\u2588\u2588 \u2588  \u2588  \u2588  \u2588\u2580\u2580\u2580\u2588\u2580 \u2588 \u2588\u2588\u2588 \u2588      \u2588\u2584\u2584\u2584\u2584\u2584\u2588 \u2584 \u2588\u2580\u2588 \u2588\u2580\u2588 \u2584\u2580\u2588 \u2588\u2584\u2584\u2584\u2584\u2584\u2588      \u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2588  \u2580\u2584\u2588\u2580\u2580\u2580\u2588 \u2584\u2588\u2584\u2584   \u2584        \u2584\u2588\u2584\u2584\u2584\u2584\u2584\u2580\u2584\u2580\u2584\u2588\u2588   \u2580 \u2584  \u2588\u2580\u2584\u2584\u2580\u2584\u2584\u2588      \u2588 \u2588\u2580\u2584\u2580\u2584\u2584\u2580\u2580\u2588\u2584\u2580\u2588\u2584\u2580\u2588\u2588\u2588\u2588\u2588\u2580\u2588\u2580\u2580\u2588 \u2588\u2584       \u2580\u2580  \u2588\u2584\u2588\u2588\u2584\u2588\u2580  \u2588 \u2580\u2588\u2580 \u2580\u2588\u2580 \u2584\u2580\u2580\u2584\u2588      \u2588\u2580 \u2580 \u2584\u2584\u2584\u2584\u2584\u2584\u2580\u2584\u2588\u2588  \u2588 \u2584\u2588\u2588\u2588\u2588\u2580\u2580 \u2588\u2584      \u2584\u2580\u2584\u2584\u2584 \u2584 \u2580\u2580\u2584\u2588\u2588\u2588\u2588\u2580\u2588\u2580  \u2580 \u2588\u2584\u2584\u2584\u2580\u2584\u2588      \u2584\u2580\u2580\u2588\u2588\u2584\u2584  \u2588\u2580\u2584\u2580\u2588\u2580\u2580 \u2588\u2580 \u2584\u2584\u2584\u2588\u2588\u2580 \u2580       \u2584\u2584\u2584\u2584\u2584\u2584\u2584 \u2588 \u2588\u2580 \u2580\u2580   \u2584\u2588\u2588 \u2584 \u2588\u2584\u2580\u2588\u2588      \u2588 \u2584\u2584\u2584 \u2588 \u2588\u2584 \u2580\u2584\u2580 \u2580\u2588\u2588  \u2588\u2584\u2584\u2584\u2588\u2584  \u2580      \u2588 \u2588\u2588\u2588 \u2588 \u2584 \u2588\u2588\u2588\u2580\u2580\u2580\u2588\u2584 \u2588\u2580\u2584 \u2588\u2588\u2584 \u2580\u2588      \u2588\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588 \u2584\u2588\u2580\u2588  \u2588 \u2580\u2588\u2588\u2584\u2584\u2584  \u2588\u2584   <\/code><\/pre>\n<p><strong>\u53c2\u8003\u94fe\u63a5\uff1a<\/strong><\/p>\n<p>[1]\u00a0What a C programmer should know about memory<\/p>\n<p>[2] vmtouch &#8211; the Virtual Memory Toucher<\/p>\n<p>[3] kernel.org &#8211; THE\u00a0\/proc FILESYSTEM<\/p>\n<p>[4] FAQ (Why is \u201cstrict overcommit\u201d a dumb idea?)<\/p>\n<p>[5] wikipedia &#8211;\u00a0Paging &#8211;\u00a0swapinness<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>7<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1705383\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tinkerer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u8c22\u4f20\u6388\u77e5\u8bc6\uff0c\u770b\u5b8c\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1705384\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : winterbells <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u597d\u4eba\u4e00\u751f\u5e73\u5b89                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1705385\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipadpro4k <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u4e2a\u6807\u9898\u5c31\u77e5\u9053\u6587\u7ae0\u7ed3\u5c3e\u6709\u4e8c\u7ef4\u7801                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1705386\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : felix021 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ipadpro4k \u5957\u8def\u591a\u4e86\u5c31\u4e60\u60ef\u4e86\uff0c\u7136\u540e\u8f6c\u5316\u7387\u5c31\u4e0b\u964d\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1705387\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mfuture <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6536\u83b7\u5f88\u591a\uff0c\u8c22\u8c22\u5927\u4f6c~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1705388\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : limboMu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u70b9\u5f00\u4e86\u82f1\u6587\u539f\u7248\uff0c\u7136\u540e\u53d1\u73b0\u8fd8\u6709\u4e00\u7bc7 everyone \u7684\u8bba\u6587\uff0c\u4efb\u91cd\u800c\u9053\u8fdc\uff0c\u611f\u8c22\u4e3b\uff0c\u6211\u53bb\u770b\u4e66\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1705389\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : felix021 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @limboMu \u55ef\uff0c\u5f00\u7bc7\u5c31\u63d0\u4e86\u3002\u90a3\u7bc7\u592a\u957f\u4e86\uff0c\u6211\u6ca1\u52c7\u6c14\u5165\u5751\u2026\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[\u8bd1] \uff23\u7a0b\u5e8f\u5458\u8be5\u77e5\u9053\u7684\u5185\u5b58\u77e5\u8bc6 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/103353"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=103353"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/103353\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103353"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}