{"id":10020918,"date":"2025-07-24T16:13:25","date_gmt":"2025-07-24T08:13:25","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020918"},"modified":"2025-07-24T16:13:25","modified_gmt":"2025-07-24T08:13:25","slug":"%e4%bb%8e%e9%a2%91%e7%b9%81%e5%91%8a%e8%ad%a6%e5%88%b0%e5%b9%b3%e7%a8%b3%e5%8f%91%e5%b8%83%ef%bc%9a%e6%9c%8d%e5%8a%a1%e5%86%b7%e5%90%af%e5%8a%a8-cpu-%e9%a3%8e%e6%9a%b4%e4%bc%98%e5%8c%96%e5%ae%9e","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020918","title":{"rendered":"\u4ece\u9891\u7e41\u544a\u8b66\u5230\u5e73\u7a33\u53d1\u5e03\uff1a\u670d\u52a1\u51b7\u542f\u52a8 CPU \u98ce\u66b4\u4f18\u5316\u5b9e\u8df5"},"content":{"rendered":"<blockquote>\n<p>\u4f5c\u8005\uff1avivo \u4e92\u8054\u7f51\u670d\u52a1\u5668\u56e2\u961f- Xie Xiaopeng<\/p>\n<p>\u672c\u6587\u9488\u5bf9\u670d\u52a1\u542f\u52a8\u540e\u51e0\u5206\u949f\u5185 CPU \u6301\u7eed\u5904\u4e8e\u9ad8\u5cf0\u72b6\u6001\u7684\u95ee\u9898\uff0c\u63d0\u51fa\u4e86\u81ea\u5df1\u7684\u5206\u6790\u601d\u8def\u4e0e\u89e3\u51b3\u65b9\u6848\u3002\u6700\u7ec8\u7ebf\u4e0a\u6548\u679c\u6bd4\u8f83\u663e\u8457\uff0c\u6210\u529f\u89e3\u51b3\u4e86\u6bcf\u6b21\u53d1\u7248\u8fc7\u7a0b\u4e2d\u9891\u7e41\u544a\u8b66\u3001\u4e1a\u52a1\u53d7\u635f\u4ee5\u53ca\u7528\u6237\u4f53\u9a8c\u4e0d\u4f73\u7684\u95ee\u9898\uff0c\u4e3a\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u589e\u6dfb\u4e86\u4e00\u9053\u91cd\u8981\u4fdd\u969c\u3002\u672c\u6587\u7684\u91cd\u70b9\u5728\u4e8e\u95ee\u9898\u7684\u53d1\u73b0\u3001\u5206\u6790\u53ca\u89e3\u51b3\u601d\u8def\u3002\u5bf9\u4e8e CPU \u76f8\u5173\u7684\u95ee\u9898\uff0c\u706b\u7130\u56fe\u548c Arthas \u662f\u975e\u5e38\u6709\u6548\u7684\u5de5\u5177\uff0c\u5efa\u8bae\u5927\u5bb6\u5728\u9047\u5230\u7c7b\u4f3c\u60c5\u51b5\u65f6\uff0c\u79ef\u6781\u5c1d\u8bd5\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u8fdb\u884c\u6392\u67e5\u548c\u89e3\u51b3\u3002<\/p>\n<\/blockquote>\n<p>1\u5206\u949f\u770b\u56fe\u6293\u4f4f\u6838\u5fc3\u89c2\u70b9\ud83d\udc47<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060401\" alt=\"\" title=\"\"><\/p>\n<h2>\u4e00\u3001\u80cc\u666f<\/h2>\n<p>\u6700\u8fd1\u6211\u4eec\u7684\u670d\u52a1\u5728\u53d1\u5e03\u6216\u91cd\u542f\u65f6\u9891\u7e41\u4ea7\u751f\u544a\u8b66\uff0c\u8fd9\u79cd\u60c5\u51b5\u4ece\u53d1\u7248\u5f00\u59cb\u4e00\u76f4\u6301\u7eed\u5230\u53d1\u7248\u7ed3\u675f\u540e\u51e0\u5206\u949f\u5185\uff0c\u89c4\u5f8b\u975e\u5e38\u660e\u663e\u3002<\/p>\n<p>\u8d77\u521d\uff0c\u6211\u4eec\u6000\u7591\u662f\u6d41\u91cf\u63a5\u5165\u8fc7\u5feb\u5bfc\u81f4\u4e86\u6b64\u95ee\u9898\u3002\u5728\u670d\u52a1\u542f\u52a8\u540e\uff0cCICD\u4f1a\u68c0\u6d4b <a href=\"https:\/\/link.segmentfault.com\/?enc=MpZAMFrMDO6ZDfORR6xMOQ%3D%3D.CfToJL4XTfY%2BPb8lRspB5A%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">check.do<\/a> \u63a5\u53e3\uff0c\u4ee5\u786e\u8ba4\u670d\u52a1\u662f\u5426\u51c6\u5907\u5c31\u7eea\u3002\u6211\u4eec\u63a8\u6d4b\uff0c<a href=\"https:\/\/link.segmentfault.com\/?enc=XjS%2BHSjdl8Gy47PtGx9EYg%3D%3D.FHEQ0KUQikskrJSbZkkOrw%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">check.do<\/a> \u63a5\u53e3\u6210\u529f\u8fd4\u56de\u540e\uff0cCICD\u7acb\u5373\u63a5\u5165\u7ebf\u4e0a\u6d41\u91cf\uff0c\u8fd9\u624d\u5f15\u53d1\u975e\u5e38\u591a\u7684\u5f02\u5e38\u544a\u8b66\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0c\u6211\u4eec\u4e0e\u8fd0\u7ef4\u56e2\u961f\u8fdb\u884c\u4e86\u6c9f\u901a\uff0c\u51b3\u5b9a\u5c06\u6d41\u91cf\u63a5\u5165\u7684\u65f6\u673a\u5ef6\u8fdf30\u79d2\u3002\u5ef6\u8fdf30\u79d2\u540e\u95ee\u9898\u8fd8\u662f\u6ca1\u6709\u5f97\u5230\u89e3\u51b3\uff0c\u544a\u8b66\u4f9d\u7136\u6301\u7eed\u4e0d\u65ad\u3002<\/p>\n<h2>\u4e8c\u3001 \u95ee\u9898\u8868\u8c61<\/h2>\n<p>\u4ee5\u7ebf\u4e0a\u67d0\u4e00\u53f0\u673a\u5668\u4e3a\u4f8b\uff0c\u5b83\u7684\u542f\u52a8\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<pre><code>2024-09-0416:09:50\u00a0INFO - \u542f\u52a8\u5e94\u7528 \uff0c\u6267\u884c\u6210\u529f\u3002\n2024-09-0416:12:36\u00a0WARN - \u68c0\u67e5\u63a5\u53e3\uff1acheck.do\uff0c\u54cd\u5e94\u7ed3\u679c\uff1aok\n2024-09-0416:13:07\u00a0INFO - \u542f\u52a8\u540e\u7b49\u5f85\u65f6\u95f4\uff08\u79d2\uff09\uff1a30\n2024-09-0416:13:07\u00a0INFO - \u6062\u590dDubbo\u6d41\u91cf\u6210\u529f\n2024-09-0416:13:39\u00a0INFO - \u6062\u590dHTTP\u6d41\u91cf\u6210\u529f\uff01\n<\/code><\/pre>\n<h3>2.1 Dubbo \u63a5\u53e3\u8d85\u65f6\u4e25\u91cd<\/h3>\n<p>\u6062\u590dHTTP\u6d41\u91cf\u540e\uff0c\u5f88\u591a\u8c03\u7528\u4e0b\u6e38\u7684Dubbo\u63a5\u53e3\u53d1\u751f\u8d85\u65f6\uff0c\u4ee5\u753b\u50cf\u63a5\u53e3\u4e3a\u4f8b\uff0c\u544a\u8b66\u5f00\u59cb\u65f6\u95f4\u4e3a\uff1a2024-09-04 16:14:07.251\uff0c\u7ed3\u675f\u65f6\u95f4\u4e3a\uff1a2024-09-04 16:17:31.224\uff0c\u671f\u95f4\u8d85\u65f6\u8bf7\u6c42\u6570\u4e3a\uff1a578\u3002<\/p>\n<h3>2.2 HTTP \u63a5\u53e3\u8d85\u65f6\u4e25\u91cd<\/h3>\n<p>\u5927\u90e8\u5206HTTP\u63a5\u53e3\u4e5f\u8d85\u65f6\u4e25\u91cd\uff0cP95\u54cd\u5e94\u65f6\u95f4\u4ece\u6b63\u5e38\u7684\u51e0\u5341\u6beb\u79d2\u98d9\u5347\u81f3\u51e0\u79d2\u949f\uff0c16:17:30\u540e\u9010\u6e10\u6062\u590d\u81f3\u6b63\u5e38\u6c34\u5e73\u3002<\/p>\n<h3>2.3 CPU\u5f02\u5e38<\/h3>\n<p>\u670d\u52a1\u53d1\u5e03\u524d\u540eCPU\u8868\u73b0\u5f02\u5e38\uff0c\u542f\u52a8\u8fc7\u7a0bCPU\u5b58\u5728\u7a81\u523a\uff0c\u63a5\u5165\u7ebf\u4e0a\u6d41\u91cf\u540e\u4e00\u6bb5\u65f6\u95f4\u5185CPU\u4f7f\u7528\u7387\u5c06\u8fd1100%\uff0c16:17:30\u540e\u9010\u6b65\u4e0b\u964d\uff0c\u6062\u590d\u5230\u6b63\u5e38\u6c34\u5e73\u3002\u4e0b\u56fe\u4e3a\u670d\u52a1\u53d1\u5e03\u524d\u540eCPU\u7684\u4f7f\u7528\u7387\u622a\u56fe\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060402\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u670d\u52a1\u53d1\u5e03\u524d\u540eCPU\u4f7f\u7528\u7387<\/p>\n<h3>2.4 Runnable\u3001Blocked\u7ebf\u7a0b\u7a81\u523a<\/h3>\n<p>\u4e0b\u56fe\u4e3a\u7ebf\u7a0b\u6570\u7684\u76f8\u5173\u76d1\u63a7\u6307\u6807\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff1a\u5728\u670d\u52a1\u53d1\u5e03\u671f\u95f4\uff0c\u6d3b\u8dc3\u7ebf\u7a0b\u6570\u6301\u7eed\u589e\u52a0\uff0c\u542f\u52a8\u671f\u95f4\u7ebf\u7a0b\u5267\u589e\uff0c\u63a5\u5165\u7ebf\u4e0a\u6d41\u91cf\u540e\u7ebf\u7a0b\u9010\u6b65\u589e\u52a0\uff0c16:17\u5206\u4e4b\u540e\u8d8b\u4e8e\u5e73\u7a33\uff0c\u5176\u4e2d16:12:30-16:12:40\u671f\u95f4\u6d3b\u8dc3\u7ebf\u7a0b\u6570\u4ece249\u589e\u52a0\u52301026\uff08\u542f\u52a8\u671f\u95f4\u4e1a\u52a1\u4fa7\u6709\u5f88\u591a\u4efb\u52a1\u5747\u4f1a\u521b\u5efa\u7ebf\u7a0b\u6c60\uff0c\u4e0d\u5f71\u54cd\u672c\u6b21\u5206\u6790\uff09<\/p>\n<p>Runnable\u7ebf\u7a0b\u6570\u4e0eBlocked\u7ebf\u7a0b\u6570\u4e5f\u6709\u7a81\u523a\uff0c\u65f6\u95f4\u662f16:13:30-16:17:30\uff0c\u4e0e\u63a5\u5165HTTP\u6d41\u91cf\u65f6\u95f4\u76f8\u7b26\uff0c\u4e0eCPU\u7a81\u523a\u65f6\u95f4\u5b8c\u5168\u4e00\u81f4\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060403\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Runnable\u7ebf\u7a0b<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060404\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Blocked\u7ebf\u7a0b<\/p>\n<h3>2.5 \u8001\u5e74\u4ee3\u4e0a\u6da8\u5feb<\/h3>\n<p>\u5728\u67e5\u770bGC\u8001\u5e74\u4ee3\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u65f6\uff0c\u6211\u4eec\u53d1\u73b0\u542f\u52a8\u540e\u672a\u63a5\u5165\u6d41\u91cf\u65f6\uff0c\u8001\u5e74\u4ee3\u5185\u5b58\u4e3a985.84MB\u3002\u800c\u5728\u63a5\u5165\u6d41\u91cf\u540e\uff0c\u622a\u6b62\u523016:17:30\uff0c\u5185\u5b58\u4f7f\u7528\u91cf\u5df2\u7ecf\u4e0a\u5347\u81f31.36GB\uff0c\u671f\u95f4\u8001\u5e74\u4ee3\u7684\u5185\u5b58\u589e\u957f\u901f\u5ea6\u8f83\u5feb\u3002<\/p>\n<h3>2.6 \u4e0b\u6e38\u4f9d\u8d56\u6b63\u5e38<\/h3>\n<p>\u4ece\u4e0a\u6e38\u89c6\u89d2\u67e5\u770b\u4e0b\u6e38\u4f9d\u8d56\u7684\u60c5\u51b5\uff0c\u968f\u4fbf\u6311\u4e00\u4e2aDubbo\u63a5\u53e3\u8d85\u65f6\u4e25\u91cd\u7684\u4e0b\u6e38\u4f9d\u8d56\uff0c\u6211\u4eec\u67e5\u770b\u4e00\u4e0b\u670d\u52a1\u7684\u76d1\u63a7\u6307\u6807\uff0c\u53d1\u73b0\u670d\u52a1\u7684\u8bf7\u6c42\u91cf\u5728\u542f\u52a8\u671f\u95f4\u6709\u7a81\u523a\uff08\u4e1a\u52a1\u4fa7\u5728\u542f\u52a8\u671f\u95f4\u4f1a\u4e3b\u52a8\u53d1\u8d77\u8c03\u7528\uff0c\u5237\u65b0\u4e00\u4e9b\u7f13\u5b58\uff0c\u6b63\u5e38\u73b0\u8c61\uff09\uff0c\u542f\u52a8\u540e\u6d41\u91cf\u51e0\u4e4e\u6ca1\u53d8\uff0c\u4f46\u662f\u6210\u529f\u7387\u5374\u6709\u660e\u663e\u4e0b\u964d\uff0c\u4e14\u6700\u5927\u54cd\u5e94\u65f6\u95f4\u663e\u8457\u589e\u52a0\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060405\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u4e0a\u6e38\u89c6\u89d2<\/p>\n<p>\u4f46\u662f\u4ece\u4e0b\u6e38\u89c6\u89d2\u518d\u770b\u670d\u52a1\u76f8\u5173\u6307\u6807\uff0c\u63a5\u53e3\u6210\u529f\u7387\u6b63\u5e38\uff0c\u4e14\u6700\u5927\u54cd\u5e94\u65f6\u95f4\u4e5f\u6b63\u5e38\uff0c\u8bf4\u660e\u4e0d\u662f\u4e0b\u6e38\u670d\u52a1\u7684\u95ee\u9898\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060406\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u4e0b\u6e38\u89c6\u89d2<\/p>\n<h2>\u4e09\u3001\u539f\u56e0\u521d\u6b65\u5224\u65ad<\/h2>\n<p>\u4ece\u76d1\u63a7\u6570\u636e\u6765\u770b\uff0c\u5728\u7ebf\u4e0a\u6d41\u91cf\u6062\u590d\u540e\uff0c\u6211\u4eec\u7684\u670d\u52a1\u5f53\u524d\u62e5\u6709\u7684\u7ebf\u7a0b\u6570\u4e0d\u8db3\u4ee5\u5904\u7406\u8fd9\u4e9b\u4e1a\u52a1\u8bf7\u6c42\uff0c\u56e0\u6b64\u5bfc\u81f4\u7cfb\u7edf\u5927\u91cf\u521b\u5efa\u4e1a\u52a1\u7ebf\u7a0b\u3002\u7531\u4e8eCPU\u7684\u65f6\u95f4\u7247\u8c03\u5ea6\u7b56\u7565\uff0c\u7ebf\u7a0b\u4e4b\u95f4\u4f1a\u9891\u7e41\u53d1\u751f\u4e0a\u4e0b\u6587\u5207\u6362\uff0c\u4ece\u800c\u5f15\u53d1CPU\u8d1f\u8f7d\u7684\u5267\u70c8\u4e0a\u5347\uff0c\u751a\u81f3\u8fbe\u5230\u9971\u548c\u72b6\u6001\u3002<\/p>\n<p>\u56e0\u6b64\u901a\u8fc7\u521d\u6b65\u5206\u6790\uff0c\u6211\u4eec\u5f97\u5230\u4ee5\u4e0b<strong>\u7ed3\u8bba<\/strong>\uff1a<\/p>\n<p>\u5f15\u8d77CPU\u98d9\u5347\u7684\u539f\u56e0\u4e3b\u8981\u662f\u7531\u4e8e\u8fc7\u591a\u7684Runnable\u72b6\u6001\u7ebf\u7a0b\u4ee5\u53ca\u9891\u7e41\u7684\u7ebf\u7a0b\u4e0a\u4e0b\u6587\u5207\u6362\u6240\u5bfc\u81f4\u3002\u6211\u4eec\u89c2\u5bdf\u5230\u7cfb\u7edf\u4e2d\u5b58\u5728\u5927\u91cf\u5df2\u542f\u52a8\u7684\u7ebf\u7a0b\uff0c\u8fd9\u4e9b\u7ebf\u7a0b\u7684\u72b6\u6001\u5728Blocked\uff08\u9501\u7b49\u5f85\u3001IO\u7b49\u5f85\u7b49\uff09\u548cRunnable\u4e4b\u95f4\u4e0d\u65ad\u53d8\u5316\u3002\u5f53\u9501\u7ade\u4e89\u6fc0\u70c8\u65f6\uff0cCPU\u98d9\u5347\u7684\u73b0\u8c61\u5c31\u5f88\u5bb9\u6613\u51fa\u73b0\u3002<\/p>\n<h2>\u56db\u3001\u5c1d\u8bd5\u521d\u6b65\u89e3\u51b3<\/h2>\n<h3>4.1 \u6d41\u91cf\u9010\u6b65\u7070\u5ea6<\/h3>\n<p>\u65e2\u7136\u6211\u4eec\u6000\u7591\u662f\u6d41\u91cf\u5168\u90e8\u63a5\u5165\u540e\uff0c\u7ebf\u7a0b\u4e0d\u8db3\u5bfc\u81f4\u7684\u95ee\u9898\uff0c\u56e0\u6b64\u9700\u8981\u5c1d\u8bd5\u6d41\u91cf\u7f13\u6162\u63a5\u5165\u662f\u5426\u80fd\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>\u6211\u4eec\u4e0e\u8fd0\u7ef4\u540c\u5b66\u7ebf\u4e0a\u968f\u673a\u627e\u4e86\u4e00\u53f0\u673a\u5668\u8fdb\u884c\u6d41\u91cf\u7070\u5ea6\u5b9e\u9a8c\uff0c\u5177\u4f53\u65f6\u95f4\u8282\u70b9\u5982\u4e0b\uff1a<\/p>\n<pre><code>2024-09-0509:55:21\u00a0\u542f\u52a8\u6210\u529f\n2024-09-0509:56:17\u00a0\u7070\u5ea61%\n2024-09-0509:57:19\u00a0\u7070\u5ea65%\n2024-09-0509:58:31\u00a0\u7070\u5ea644%\n2024-09-0510:03:51\u00a0\u5f00\u59cb\u64cd\u4f5c\u5168\u91cf\n2024-09-0510:08:10\u00a0\u5168\u91cf\u5b8c\u6210\n<\/code><\/pre>\n<p>\u518d\u89c2\u5bdf\u4e00\u4e0b\u76f8\u5173\u6307\u6807\uff0c\u6211\u4eec\u53d1\u73b0\u5404\u9879\u6307\u6807\u5747\u6b63\u5e38\uff1aCPU\u4f7f\u7528\u7387\u4e0d\u518d\u6709\u7a81\u523a\uff0cRunnable\u7ebf\u7a0b\u6570\u548cBlocked\u7ebf\u7a0b\u6570\u4e5f\u4fdd\u6301\u7a33\u5b9a\uff0c\u4e4b\u524d\u7684\u8d1f\u8f7d\u5c16\u5cf0\u73b0\u8c61\u5df2\u6d88\u5931\u3002\u540c\u65f6\u5f02\u5e38\u8d85\u65f6\u7684\u65e5\u5fd7\u8bb0\u5f55\u4e5f\u4e0d\u518d\u51fa\u73b0\uff0c\u8001\u5e74\u4ee3\u5185\u5b58\u7684\u589e\u957f\u901f\u5ea6\u7f13\u6162\uff0cHTTP\u63a5\u53e3\u3001Dubbo\u63a5\u53e3P95\u54cd\u5e94\u65f6\u95f4\u6b63\u5e38\u3002\u7531\u6b64\u53ef\u89c1\uff0c\u6d41\u91cf\u7070\u5ea6\u53ef\u4ee5\u89e3\u51b3\u8be5\u95ee\u9898\u3002<\/p>\n<p><strong>\u2460 CPU\u4f7f\u7528\u7387\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060407\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>CPU\u4f7f\u7528\u7387<\/p>\n<p><strong>\u2461 \u7ebf\u7a0b\u6307\u6807\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060408\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Runnable\u7ebf\u7a0b<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060409\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Blocked\u7ebf\u7a0b<\/p>\n<h3>4.2 \u7f13\u5b58\u9884\u70ed<\/h3>\n<p>\u5728\u524d\u6587\u4e2d\u63d0\u5230\uff0c\u63a5\u5165\u7ebf\u4e0a\u6d41\u91cf\u540e\uff0c\u8001\u5e74\u4ee3\u7684\u5185\u5b58\u589e\u957f\u8f83\u5feb\uff0c\u56e0\u6b64\u6211\u4eec\u63a8\u6d4b\u5728\u670d\u52a1\u542f\u52a8\u521d\u671f\uff0c\u7531\u4e8e\u5c1a\u672a\u52a0\u8f7d\u76f8\u5173\u7684\u7f13\u5b58\u6570\u636e\uff0c\u5f53\u5927\u91cf\u8bf7\u6c42\u6d8c\u5165\u65f6\uff0c\u672a\u547d\u4e2d\u7f13\u5b58\u7684\u60c5\u51b5\u9891\u7e41\u53d1\u751f\uff0c\u8fd9\u8feb\u4f7f\u7cfb\u7edf\u4e0d\u65ad\u5411\u4e0b\u6e38\u8bf7\u6c42\u4ee5\u52a0\u8f7d\u7f13\u5b58\uff0c\u4ece\u800c\u5bfc\u81f4\u63a5\u53e3\u54cd\u5e94\u53d8\u6162\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u9700\u8981\u9a8c\u8bc1\u9884\u70ed\u7f13\u5b58\u7684\u6709\u6548\u6027\uff0c\u4ee5\u786e\u5b9a\u662f\u5426\u80fd\u591f\u6539\u5584\u8fd9\u4e00\u95ee\u9898\u3002<\/p>\n<p>\u7f13\u5b58\u9884\u70ed\u7684<strong>\u4e3b\u8981\u4f5c\u7528\u548c\u76ee\u7684<\/strong>\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li><strong>\u63d0\u9ad8\u7f13\u5b58\u547d\u4e2d\u7387<\/strong>\uff1a\u901a\u8fc7\u9884\u5148\u52a0\u8f7d\u70ed\u70b9\u6570\u636e\uff0c\u80fd\u591f\u663e\u8457\u63d0\u5347\u7f13\u5b58\u7684\u547d\u4e2d\u7387\uff0c\u4ece\u800c\u51cf\u5c11\u5bf9\u540e\u7aef\u6570\u636e\u6e90\uff08\u5982\u6570\u636e\u5e93\uff09\u7684\u8bbf\u95ee\uff0c\u964d\u4f4e\u7cfb\u7edf\u8d1f\u8f7d\u3002<\/li>\n<li><strong>\u4fdd\u6301\u670d\u52a1\u6027\u80fd\u7a33\u5b9a<\/strong>\uff1a\u5728\u670d\u52a1\u542f\u52a8\u6216\u7f13\u5b58\u5931\u6548\u4e4b\u540e\uff0c\u7f13\u5b58\u9884\u70ed\u53ef\u4ee5\u6709\u6548\u9632\u6b62\u8bf7\u6c42\u5bf9\u540e\u7aef\u6570\u636e\u6e90\u65bd\u52a0\u7a81\u53d1\u538b\u529b\uff0c\u4ece\u800c\u786e\u4fdd\u670d\u52a1\u6027\u80fd\u7684\u7a33\u5b9a\u6027\u3002<\/li>\n<li><strong>\u4f18\u5316\u7528\u6237\u4f53\u9a8c<\/strong>\uff1a\u7531\u4e8e\u70ed\u70b9\u6570\u636e\u5df2\u88ab\u9884\u5148\u52a0\u8f7d\u5230\u7f13\u5b58\u4e2d\uff0c\u7528\u6237\u5728\u8bf7\u6c42\u8fd9\u4e9b\u6570\u636e\u65f6\u80fd\u591f\u83b7\u5f97\u66f4\u5feb\u7684\u54cd\u5e94\u901f\u5ea6\uff0c\u4ece\u800c\u663e\u8457\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002<\/li>\n<\/ul>\n<p><strong>\u65b9\u6848<\/strong>\u5982\u4e0b\uff1a<\/p>\n<p>\u6211\u4eec\u5c06\u68b3\u7406\u672c\u5730\u7f13\u5b58\u4fe1\u606f\uff0c\u6839\u636e\u8bbf\u95ee\u91cf\u548c\u7f13\u5b58\u5927\u5c0f\u533a\u5206\u6570\u636e\u7684\u91cd\u8981\u7a0b\u5ea6\uff0c\u5b9a\u671f\u5c06\u91cd\u8981\u7684\u7f13\u5b58\u4fe1\u606f\u5237\u65b0\u81f3Redis\u4e2d\u3002\u5728\u670d\u52a1\u542f\u52a8\u540e\uff0c\u672a\u63a5\u5165\u7ebf\u4e0a\u6d41\u91cf\u4e4b\u524d\uff0c\u6211\u4eec\u5c06\u4f18\u5148\u4eceRedis\u4e2d\u8fdb\u884c\u6570\u636e\u7684\u9884\u52a0\u8f7d\u3002\u901a\u8fc7\u8fd9\u4e00\u63aa\u65bd\uff0c\u786e\u4fdd\u7cfb\u7edf\u5728\u9ad8\u6d41\u91cf\u73af\u5883\u4e0b\u7684\u7a33\u5b9a\u6027\u548c\u6027\u80fd\u3002<\/p>\n<p>\u5b9e\u9a8c\u7ed3\u679c\u663e\u793a\uff0c\u589e\u52a0\u7f13\u5b58\u9884\u70ed\u540e\uff0c\u95ee\u9898\u5e76\u672a\u5f97\u5230\u6709\u6548\u89e3\u51b3\uff0c\u8868\u73b0\u5dee\u5f02\u5fae\u4e4e\u5176\u5fae\u3002<\/p>\n<p>\u4ec5\u4ec5\u9884\u70ed\u91cd\u8981\u7f13\u5b58\u65e0\u6cd5\u89e3\u51b3\u5f53\u524d\u95ee\u9898\u3002\u7cfb\u7edf\u5728\u542f\u52a8\u65f6\u9700\u8981\u9884\u70ed\u7684\u5185\u5bb9\u76f8\u5bf9\u8f83\u591a\uff0c\u540c\u65f6\u5404\u7c7b\u4e2d\u95f4\u4ef6\u4e5f\u6709\u81ea\u8eab\u7684\u7f13\u5b58\u9700\u8981\u9884\u70ed\u3002\u56e0\u6b64\u4ec5\u9884\u70ed\u4e1a\u52a1\u81ea\u5b9a\u4e49\u7684\u5185\u5b58\u7f13\u5b58\uff0c\u6548\u679c\u975e\u5e38\u6709\u9650\u3002<\/p>\n<p>\u56de\u987e\u4e4b\u524d\u7684\u539f\u56e0\u5206\u6790\uff0c\u6211\u4eec\u4ec5\u4ec5\u5173\u6ce8\u4e86\u8868\u9762\u73b0\u8c61\uff0c\u5982CPU\u7684\u4e0a\u6da8\u548c\u7ebf\u7a0b\u6570\u7684\u589e\u52a0\uff0c\u800c\u672a\u6df1\u5165\u6316\u6398\u95ee\u9898\u7684\u672c\u8d28\u3002\u6211\u4eec\u9700\u8981\u63a2\u8ba8\u7ebf\u7a0b\u6570\u4e3a\u4f55\u4e0a\u5347\u3001CPU\u4e3a\u4f55\u98d9\u5347\uff0c\u63a5\u4e0b\u6765\u5c06\u8fdb\u884c\u66f4\u6df1\u5165\u7684\u5206\u6790\uff0c\u4ee5\u627e\u51fa\u95ee\u9898\u7684\u6839\u672c\u539f\u56e0\u3002<\/p>\n<h2>\u4e94\u3001\u5206\u6790\u95ee\u9898<\/h2>\n<h3>5.1 \u521d\u6b65\u5206\u6790\u5806\u6808\u4e0eCPU\u706b\u7130\u56fe<\/h3>\n<p>\u6211\u4eec\u9009\u62e9\u4e86\u4e00\u53f0\u7ebf\u4e0a\u673a\u5668\u8fdb\u884c\u670d\u52a1\u91cd\u542f\uff0c\u5e76\u5728\u63a5\u5165\u7ebf\u4e0a\u6d41\u91cf\u540e\u7684\u51e0\u5206\u949f\u5185\u5bfc\u51fa\u4e86\u7a0b\u5e8f\u7684\u7ebf\u7a0b\u5806\u6808\u4fe1\u606f\uff0c\u8fdb\u884c\u5206\u6790\uff1a<\/p>\n<ul>\n<li>Runnable \u7ebf\u7a0b\u6570\u663e\u8457\u589e\u591a\uff0c\u5360\u6bd4\u8fbe\u523029%\uff0c\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cRunnable\u7ebf\u7a0b\u6570\u7ea6\u4e3a70\u4e2a\uff0c\u800c\u6b64\u65f6\u5374\u6fc0\u589e\u81f3462\u4e2a\uff1b<\/li>\n<li>\u8fdb\u4e00\u6b65\u67e5\u770b Runnable \u7ebf\u7a0b\uff0c\u53d1\u73b0\u5927\u90e8\u5206\u7ebf\u7a0b\u4e3a catalina-exec \u7ebf\u7a0b\uff08380\u4e2a\uff09\uff0c\u8fd9\u662fTomcat\u7528\u4e8e\u6267\u884cSpring MVC\u5e94\u7528\u4e2dServlet\u8bf7\u6c42\u7684\u7ebf\u7a0b\u3002\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u8fd9\u7c7b\u7ebf\u7a0b\u7684\u6570\u91cf\u4ec5\u6709\u51e0\u4e2a\uff1b<\/li>\n<li>\u5728\u8fd9\u4e9bRunnable\u7ebf\u7a0b\u4e2d\uff0c\u6709201\u4e2a\u7ebf\u7a0b\u5747\u88ab\u963b\u585e\u5728 org.springframework.beans.PropertyMatches.calculateStringDistance(PropertyMatches.java:170) \u8fd9\u4e2a\u65b9\u6cd5\u4e0a\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u4e00\u6b65\u5206\u6790\u5176\u539f\u56e0\u3002<\/li>\n<\/ul>\n<p>\u770b\u4e86\u5806\u6808\u4fe1\u606f\u540e\uff0c\u5e94\u8be5\u6709\u4e2a\u7591\u95ee\uff1a\u4e3a\u4ec0\u4e48\u542f\u52a8\u4e86\u8fd9\u4e48\u591a\u7684tomcat\u7ebf\u7a0b\uff1f<\/p>\n<p>\u6211\u4eec\u63a8\u6d4b\u539f\u56e0\u5728\u4e8e\u670d\u52a1\u521a\u542f\u52a8\u65f6\uff0c\u7cfb\u7edf\u5c1a\u672a\u52a0\u8f7d\u4efb\u4f55\u7f13\u5b58\uff0c\u6240\u6709\u6570\u636e\u90fd\u9700\u8981\u8fdb\u884c\u9996\u6b21\u52a0\u8f7d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u670d\u52a1\u65e0\u6cd5\u5feb\u901f\u54cd\u5e94\u7528\u6237\u8bf7\u6c42\uff0c\u5bfc\u81f4\u63a5\u53e3\u7684\u54cd\u5e94\u65f6\u95f4\uff08RT\uff09\u663e\u8457\u4e0a\u5347\u3002\u5728\u76f8\u540c\u7684QPS\u7684\u60c5\u51b5\u4e0b\uff0c\u4e3a\u4e86\u5904\u7406\u4e0d\u65ad\u589e\u52a0\u7684\u4e1a\u52a1\u8bf7\u6c42\uff0c\u7cfb\u7edf\u4e0d\u5f97\u4e0d\u521b\u5efa\u66f4\u591a\u7684Tomcat\u7ebf\u7a0b\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u63a5\u5165Arthas\u5de5\u5177\uff0c\u91c7\u96c6CPU\u706b\u7130\u56fe\u4ee5\u8fdb\u884c\u6df1\u5165\u5206\u6790\uff0cCPU\u706b\u7130\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060410\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u5f02\u5e38CPU\u706b\u7130\u56fe<\/p>\n<p>\u5206\u6790\u7ed3\u679c\u663e\u793a\uff0cCPU\u8017\u65f6\u4e3b\u8981\u96c6\u4e2d\u5728calculateStringDistance\u65b9\u6cd5\uff0c\u8fd9\u4e0e\u6211\u4eec\u4e4b\u524d\u7684\u7ebf\u7a0b\u5806\u6808\u5206\u6790\u7ed3\u679c\u4e00\u81f4\u3002\u5728\u670d\u52a1\u542f\u52a8\u65f6\u7684CPU\u706b\u7130\u56fe\u4e2d\uff0ccalculateStringDistance\u65b9\u6cd5\u7684CPU\u6d88\u8017\u5360\u6bd4\u9ad8\u8fbe16.68% + 39.09% + 8.38% = 64.15%\uff0c\u6574\u4f53CPU\u4f7f\u7528\u7387\u63a5\u8fd197%\u3002<\/p>\n<p>\u7ecf\u8fc7\u4e00\u6bb5\u65f6\u95f4\u7684\u8fd0\u884c\u540e\uff0c\u518d\u89c2\u5bdf\u6b63\u5e38\u60c5\u51b5\u4e0b\u7684CPU\u706b\u7130\u56fe\uff0ccalculateStringDistance\u65b9\u6cd5\u7684CPU\u6d88\u8017\u5360\u6bd4\u964d\u81f33.39% + 8.57% + 1.78% = 13.74%\uff0c\u6574\u4f53CPU\u4f7f\u7528\u7387\u5219\u5f98\u5f8a\u572825%\u81f342%\u4e4b\u95f4\u3002<\/p>\n<p>\u8fd9\u4e00\u53d8\u5316\u8868\u660e\uff0c\u968f\u7740\u7cfb\u7edf\u7684\u7a33\u5b9a\u8fd0\u884c\uff0cCPU\u8d1f\u8f7d\u9010\u6e10\u5f97\u5230\u7f13\u89e3\uff0c\u4f46calculateStringDistance\u65b9\u6cd5\u4ecd\u7136\u662f\u6027\u80fd\u74f6\u9888\u4e4b\u4e00\u3002\u5b83\u867d\u7136\u4e0d\u662fCPU\u4f7f\u7528\u7387\u98d9\u5347\u7684\u6839\u56e0\uff0c\u4f46\u5b83\u5728\u670d\u52a1\u542f\u52a8\u540e\u8fdb\u4e00\u6b65\u52a0\u5267\u4e86CPU\u7684\u8d1f\u8f7d\u3002<\/p>\n<h4>5.1.1 calculateStringDistance\u52a0\u5267CPU\u66b4\u6da8<\/h4>\n<p>\u5728\u76f8\u540cQPS\u7684\u60c5\u51b5\u4e0b\uff0c\u4e3a\u4ec0\u4e48\u5728\u670d\u52a1\u542f\u52a8\u540e\u7684\u51e0\u5206\u949f\u5185calculateStringDistance\u65b9\u6cd5\u6d88\u8017\u7684CPU\u8d44\u6e90\u4e25\u91cd\uff0c\u800c\u7ecf\u8fc7\u4e00\u6bb5\u65f6\u95f4\u540e\uff0c\u8fd9\u4e00\u6d88\u8017\u53c8\u6709\u6240\u51cf\u5c0f\uff1f<\/p>\n<p>\u524d\u6587\u7684\u5206\u6790\u6307\u51fa\uff0c\u670d\u52a1\u521a\u542f\u52a8\u65f6\uff0c\u6d41\u91cf\u77ac\u95f4\u6062\u590d\uff0c\u5bfc\u81f4\u7cfb\u7edf\u9700\u8981\u521b\u5efa\u5927\u91cf\u7684\u4e1a\u52a1\u7ebf\u7a0b\u3002\u8fd9\u4e9b\u7ebf\u7a0b\u5728\u5904\u7406\u8bf7\u6c42\u65f6\uff0c\u90fd\u4f1a\u6267\u884ccalculateStringDistance\u65b9\u6cd5\u3002\u7531\u4e8e\u8be5\u65b9\u6cd5\u672c\u8eab\u7684\u8ba1\u7b97\u5f00\u9500\u8f83\u5927\uff0c\u4e14\u5e76\u53d1\u6267\u884c\u7684\u7ebf\u7a0b\u6570\u91cf\u8d8a\u591a\uff0cCPU\u7684\u6d88\u8017\u5c31\u4f1a\u8d8a\u663e\u8457\u3002\u56e0\u6b64\u5728\u670d\u52a1\u542f\u52a8\u521d\u671f\uff0cCPU\u7684\u8d1f\u8f7d\u6025\u5267\u4e0a\u5347\u3002\u968f\u7740\u8fd0\u884c\u65f6\u95f4\u7684\u5ef6\u957f\uff0c\u4e1a\u52a1\u7ebf\u7a0b\u7684\u521b\u5efa\u548c\u6267\u884c\u4e5f\u8d8b\u4e8e\u5e73\u8861\uff0c\u5e76\u53d1\u6267\u884c\u7684\u7ebf\u7a0b\u6570\u91cf\u5927\u5927\u51cf\u5c0f\uff0cCPU\u6d88\u8017\u4e5f\u968f\u4e4b\u51cf\u5c0f\u3002<\/p>\n<h4>5.1.2 calculateStringDistance\u6e90\u7801\u5206\u6790<\/h4>\n<p>calculateStringDistance\u65b9\u6cd5\u7684\u529f\u80fd\u662f\u6839\u636eLevenshtein\u7b97\u6cd5\u8ba1\u7b97\u7ed9\u5b9a\u4e24\u4e2a\u5b57\u7b26\u4e32\u4e4b\u95f4\u7684\u8ddd\u79bb\u6216\u76f8\u4f3c\u5ea6\u3002\u901a\u8fc7\u5206\u6790\u5176\u6e90\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u5728\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u65f6\uff0c\u8be5\u65b9\u6cd5\u91c7\u7528\u4e86\u5d4c\u5957\u7684for\u5faa\u73af\u7ed3\u6784\u3002\u5728\u8fd9\u4e9b\u5faa\u73af\u4e2d\uff0c\u6d89\u53ca\u5230length\u3001chatAt\u548cMath.min\u51fd\u6570\u7684\u8c03\u7528\uff0c\u8fd9\u4f7f\u5f97\u8be5\u65b9\u6cd5\u7684\u8ba1\u7b97\u590d\u6742\u5ea6\u76f8\u5bf9\u8f83\u9ad8\u3002\u8c03\u7528\u91cf\u8d8a\u5927\uff0cCPU\u6d88\u8017\u5c31\u4f1a\u8d8a\u4e25\u91cd\u3002\u6839\u636eCPU\u706b\u7130\u56fe\u7684\u5206\u6790\uff0c\u53d1\u73b0\u8fd9\u4e09\u4e2a\u51fd\u6570\u7684CPU\u6d88\u8017\u5360\u6bd4\u4e0ecalculateStringDistance\u65b9\u6cd5\u7684CPU\u6d88\u8017\u5360\u6bd4\u4e4b\u95f4\u7684\u6bd4\u4f8b\u9ad8\u8fbe78%\u3002\u56e0\u6b64\u5728\u8c03\u7528\u8be5\u65b9\u6cd5\u65f6\u8981\u5c0f\u5fc3\uff0c\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\uff0c\u8be5\u65b9\u6cd5\u5f88\u6709\u53ef\u80fd\u6210\u4e3a\u7cfb\u7edf\u7684\u6027\u80fd\u74f6\u9888\uff0c\u5bf9CPU\u4ea7\u751f\u5f71\u54cd\u3002<\/p>\n<pre><code>private\u00a0static\u00a0int\u00a0calculateStringDistance(String s1, String s2){\n\u00a0\u00a0if\u00a0(s1.isEmpty()) {\n\u00a0 \u00a0\u00a0return\u00a0s2.length();\n\u00a0 }\n\u00a0\u00a0if\u00a0(s2.isEmpty()) {\n\u00a0 \u00a0\u00a0return\u00a0s1.length();\n\u00a0 }\n\n\u00a0\u00a0int[][] d = newint[s1.length() +\u00a01][s2.length() +\u00a01];\n\u00a0\u00a0for\u00a0(int\u00a0i =\u00a00; i &lt;= s1.length(); i++) {\n\u00a0 \u00a0 d[i][0] = i;\n\u00a0 }\n\u00a0\u00a0for\u00a0(int\u00a0j =\u00a00; j &lt;= s2.length(); j++) {\n\u00a0 \u00a0 d[0][j] = j;\n\u00a0 }\n\n\u00a0\u00a0for\u00a0(int\u00a0i =\u00a01; i &lt;= s1.length(); i++) {\n\u00a0 \u00a0\u00a0char\u00a0c1 = s1.charAt(i -\u00a01);\n\u00a0 \u00a0\u00a0for\u00a0(int\u00a0j =\u00a01; j &lt;= s2.length(); j++) {\n\u00a0 \u00a0 \u00a0\u00a0int\u00a0cost;\n\u00a0 \u00a0 \u00a0\u00a0char\u00a0c2 = s2.charAt(j -\u00a01);\n\u00a0 \u00a0 \u00a0\u00a0if\u00a0(c1 == c2) {\n\u00a0 \u00a0 \u00a0 \u00a0 cost =\u00a00;\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0\u00a0else\u00a0{\n\u00a0 \u00a0 \u00a0 \u00a0 cost =\u00a01;\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 d[i][j] = Math.min(Math.min(d[i -\u00a01][j] +\u00a01, d[i][j -\u00a01] +\u00a01), d[i -\u00a01][j -\u00a01] + cost);\n\u00a0 \u00a0 }\n\u00a0 }\n\n\u00a0\u00a0return\u00a0d[s1.length()][s2.length()];\n}\n}\n<\/code><\/pre>\n<p>calculateStringDistance\u65b9\u6cd5\u662f\u5982\u4f55\u89e6\u53d1\u7684\uff1f\u901a\u8fc7\u67e5\u8be2\u5806\u6808\u4fe1\u606f\u5e76\u67e5\u770b\u6e90\u4ee3\u7801\uff0c\u6211\u4eec\u53d1\u73b0\u8fd9\u662fSpring\u6846\u67b6\u5728\u89e3\u6790\u8bf7\u6c42\u53c2\u6570\u5e76\u6ce8\u5165\u5c5e\u6027\u7684\u8fc7\u7a0b\u4e2d\u6240\u89e6\u53d1\u7684\u3002\u5806\u6808\u4fe1\u606f\u5982\u4e0b\uff0c\u4ece\u4e0a\u5230\u4e0b\u9010\u6b65\u5206\u6790\u5806\u6808\uff0c\u6211\u4eec\u91cd\u70b9\u5206\u6790setPropertyValues\u548ccreateNotWritable-<\/p>\n<p>PropertyException\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u3002<\/p>\n<pre><code>&quot;catalina-exec-485&quot;\u00a0#975 daemon prio=5 os_prio=0 tid=0x00007f50e825f000 nid=0x3375 runnable [0x00007f5043ea4000]\n\u00a0 \u00a0java.lang.Thread.State: RUNNABLE\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.PropertyMatches.calculateStringDistance(PropertyMatches.java:170)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.PropertyMatches.access$100(PropertyMatches.java:44)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.PropertyMatches$BeanPropertyMatches.calculateMatches(PropertyMatches.java:208)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.PropertyMatches$BeanPropertyMatches.&lt;init&gt;(PropertyMatches.java:193)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.PropertyMatches.forProperty(PropertyMatches.java:68)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.PropertyMatches.forProperty(PropertyMatches.java:58)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:237)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:435)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:290)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278)\n\u00a0 \u00a0 \u00a0 at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)\n\u00a0 \u00a0 \u00a0 at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:860)\n\u00a0 \u00a0 \u00a0 at org.springframework.validation.DataBinder.doBind(DataBinder.java:756)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:192)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:106)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.bindRequestParameters(ServletModelAttributeMethodProcessor.java:152)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:111)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:158)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest$original$3Q7HrFjh(InvocableHandlerMethod.java:128)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest$original$3Q7HrFjh$accessor$ykGmQRZT(InvocableHandlerMethod.java)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.method.support.InvocableHandlerMethod$auxiliary$Wny4v5BZ.call(Unknown Source)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:849)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:760)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)\n\u00a0 \u00a0 \u00a0 at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)\n\u00a0 \u00a0 \u00a0 at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)\n\u00a0 \u00a0 \u00a0 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.StandardWrapperValve.invoke$original$Y7IhKDGv(StandardWrapperValve.java:219)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.StandardWrapperValve.invoke$original$Y7IhKDGv$accessor$4IDmuys6(StandardWrapperValve.java)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.StandardWrapperValve$auxiliary$1SL1DIkO.call(Unknown Source)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)\n\u00a0 \u00a0 \u00a0 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)\n\u00a0 \u00a0 \u00a0 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1136)\n\u00a0 \u00a0 \u00a0 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)\n\u00a0 \u00a0 \u00a0 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1775)\n\u00a0 \u00a0 \u00a0 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1734)\n\u00a0 \u00a0 \u00a0 - locked &lt;0x000000070f1dc100&gt; (a org.apache.tomcat.util.net.NioChannel)\n\u00a0 \u00a0 \u00a0 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\u00a0 \u00a0 \u00a0 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\u00a0 \u00a0 \u00a0 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\u00a0 \u00a0 \u00a0 at java.lang.Thread.run(Thread.java:748)\n<\/code><\/pre>\n<p>\u5148\u5206\u6790setPropertyValues\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u8d1f\u8d23\u5c06\u8bf7\u6c42\u4e2d\u7684\u53c2\u6570\u6620\u5c04\u5230\u76ee\u6807\u5bf9\u8c61\u7684\u5c5e\u6027\u4e0a\uff0c\u4e3b\u8981\u662f\u904d\u5386\u5c5e\u6027\u5217\u8868\u8fdb\u884c\u8d4b\u503c\u5e76\u8fdb\u884c\u5f02\u5e38\u7edf\u4e00\u5904\u7406\uff0c\u5355\u4e2a\u5c5e\u6027\u7684\u6ce8\u5165\u7ee7\u7eed\u770bsetPropertyValue\u65b9\u6cd5\u3002<\/p>\n<pre><code>public\u00a0void\u00a0setPropertyValues(PropertyValues pvs,\u00a0boolean\u00a0ignoreUnknown,\u00a0boolean\u00a0ignoreInvalid)\n\u00a0 \u00a0 \u00a0\u00a0throws\u00a0BeansException {\n\u00a0 \u00a0\u00a0\/\/ \u58f0\u660ePropertyAccessException\u96c6\u5408\uff0c\u4fdd\u5b58\u5355\u4e2a\u5c5e\u6027\u6ce8\u5165\u65f6\u629b\u51fa\u7684PropertyAccessException\u5f02\u5e38\n\u00a0 List&lt;PropertyAccessException&gt; propertyAccessExceptions =\u00a0null;\n\u00a0 \u00a0\u00a0\/\/ \u83b7\u53d6\u5c5e\u6027\u5217\u8868\n\u00a0 List&lt;PropertyValue&gt; propertyValues = (pvs\u00a0instanceof\u00a0MutablePropertyValues ?\n\u00a0 \u00a0 \u00a0 ((MutablePropertyValues) pvs).getPropertyValueList() : Arrays.asList(pvs.getPropertyValues()));\n\u00a0\u00a0for\u00a0(PropertyValue pv : propertyValues) {\n\u00a0 \u00a0\u00a0try\u00a0{\n\u00a0 \u00a0 \u00a0\u00a0\/\/ \u5355\u4e2a\u5c5e\u6027\u7684\u6ce8\u5165\uff0c\u6ce8\u610f\uff1a\u6b64\u65b9\u6cd5\u53ef\u80fd\u4f1a\u5f15\u53d1\u4efb\u610f\u7684BeansException\uff0c\u5982\u679c\u5b58\u5728\u4e25\u91cd\u6545\u969c\uff08\u4f8b\u5982\u6ca1\u6709\u5339\u914d\u7684\u5b57\u6bb5\uff09\uff0c\u5219\u4e0d\u4f1a\u5728\u6b64\u5904\u6355\u83b7\u8be5\u5f02\u5e38\u3002\u6211\u4eec\u53ef\u4ee5\u5c1d\u8bd5\u53ea\u5904\u7406\u4e0d\u592a\u4e25\u91cd\u7684\u5f02\u5e38\u3002\n\u00a0 \u00a0 \u00a0 setPropertyValue(pv);\n\u00a0 \u00a0 }\n\u00a0 \u00a0\u00a0catch\u00a0(NotWritablePropertyException ex) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u9ed8\u8ba4\u662ftrue\uff0c\u5ffd\u7565\u672a\u77e5\u5c5e\u6027\uff0c\u56e0\u6b64\u4e0d\u4f1a\u629b\u5f02\u5e38\n\u00a0 \u00a0 \u00a0\u00a0if\u00a0(!ignoreUnknown) {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0throw\u00a0ex;\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0\u00a0\/\/ Otherwise, just ignore it and continue...\n\u00a0 \u00a0 }\n\u00a0 \u00a0\u00a0catch\u00a0(NullValueInNestedPathException ex) {\n\u00a0 \u00a0 \u00a0\u00a0if\u00a0(!ignoreInvalid) {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0throw\u00a0ex;\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0\u00a0\/\/ Otherwise, just ignore it and continue...\n\u00a0 \u00a0 }\n\u00a0 \u00a0\u00a0catch\u00a0(PropertyAccessException ex) {\n\u00a0 \u00a0 \u00a0\u00a0if\u00a0(propertyAccessExceptions ==\u00a0null) {\n\u00a0 \u00a0 \u00a0 \u00a0 propertyAccessExceptions =\u00a0new\u00a0LinkedList&lt;PropertyAccessException&gt;();\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 propertyAccessExceptions.add(ex);\n\u00a0 \u00a0 }\n\u00a0 }\n\n\u00a0\u00a0\/\/ \u5982\u679c propertyAccessExceptions \u4e0d\u4e3a\u7a7a\uff0c\u9700\u8981\u6574\u5408\u8d77\u6765\uff0c\u629b\u4e00\u4e2a\u590d\u5408\u5f02\u5e38 PropertyBatchUpdateException\n\u00a0\u00a0if\u00a0(propertyAccessExceptions !=\u00a0null) {\n\u00a0 \u00a0 PropertyAccessException[] paeArray =\n\u00a0 \u00a0 \u00a0 \u00a0 propertyAccessExceptions.toArray(new\u00a0PropertyAccessException[propertyAccessExceptions.size()]);\n\u00a0 \u00a0 thrownew\u00a0PropertyBatchUpdateException(paeArray);\n\u00a0 }\n}\n<\/code><\/pre>\n<p>propertyValues \u5c5e\u6027\u7684\u7ed3\u6784\u5982\u4e0b\uff0c\u5b83\u5305\u542b\u4e86\u4ece\u4e0a\u6e38\u4f20\u9012\u8fc7\u6765\u7684\u6240\u6709\u53c2\u6570\u3002\u8fd9\u4e9b\u53c2\u6570\u88ab\u5c01\u88c5\u6210\u4e00\u4e2a\u96c6\u5408\uff0c\u4fbf\u4e8e\u540e\u7eed\u7684\u5904\u7406\u548c\u6ce8\u5165\u3002<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060411\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>propertyValues \u5c5e\u6027<\/p>\n<p>\u5206\u6790setPropertyValue\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u4e3b\u8981\u4f5c\u7528\u662f\u89e3\u6790\u5c5e\u6027\u503c\uff0c\u5982\u679c\u5b58\u5728\u5d4c\u5957\u5c5e\u6027\uff0c\u5219\u9012\u5f52\u89e3\u6790\u8bbe\u7f6e\u6700\u7ec8\u5bf9\u5e94\u7684\u5c5e\u6027\u503c\uff0c\u65b9\u6cd5\u6700\u540e\u90fd\u4f1a\u8c03\u7528setPropertyValue(tokens, pv)\u65b9\u6cd5\u3002<\/p>\n<pre><code>public\u00a0void\u00a0setPropertyValue(PropertyValue pv)\u00a0throws\u00a0BeansException {\n\u00a0\u00a0PropertyTokenHolder\u00a0tokens\u00a0=\u00a0(PropertyTokenHolder) pv.resolvedTokens;\n\u00a0\u00a0if\u00a0(tokens ==\u00a0null) {\n\u00a0 \u00a0\u00a0String\u00a0propertyName\u00a0=\u00a0pv.getName();\n\u00a0 \u00a0 AbstractNestablePropertyAccessor nestedPa;\n\u00a0 \u00a0\u00a0try\u00a0{\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ \u786e\u5b9a\u7ed9\u5b9a\u5c5e\u6027\u8def\u5f84\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5d4c\u5957\u5c5e\u6027\u5206\u9694\u7b26\uff0c\u5ffd\u7565\u952e\u4e2d\u7684\u70b9\uff08\u5982 \u201cmap[my.key]\u201d\uff09\u3002\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ \u5f53\u914d\u7f6e\u7684\u5c5e\u6027\u540dpropertyName\u4e2d\u5305\u542b'.'\u8fd9\u6837\u5b57\u7b26\u65f6\uff0c\u4ee3\u8868\u9700\u8981\u8bbe\u7f6e\u5d4c\u5957\u5c5e\u6027\n\u00a0 \u00a0 \u00a0 \u00a0\/\/ \u5982\u679c\u5b58\u5728\u5d4c\u5957\u5c5e\u6027\uff0cSpring\u4f1a\u9012\u5f52\u5411\u4e0b\u83b7\u53d6\u6700\u7ec8\u8bbe\u7f6e\u7684\u5c5e\u6027\uff0c\u6bd4\u5982\uff1aa.b.c\uff0cSpring\u4f1a\u9012\u5f52\u8c03\u7528\u83b7\u53d6\u5230b\uff0cc\u662f\u9700\u8981\u8bbe\u7f6e\u7684\u5c5e\u6027\n\u00a0 \u00a0 \u00a0 \u00a0\/\/ \u5982\u679c\u6ca1\u6709\u5d4c\u5957\u5c5e\u6027\u7684\u8bdd\u3002\u4f1a\u8fd4\u56de\u81ea\u8eab\n\u00a0 \u00a0 \u00a0 nestedPa = getPropertyAccessorForPropertyPath(propertyName);\n\u00a0 \u00a0 }\n\u00a0 \u00a0\u00a0catch\u00a0(NotReadablePropertyException ex) {\n\u00a0 \u00a0 \u00a0 thrownew\u00a0NotWritablePropertyException(getRootClass(),\u00a0this.nestedPath + propertyName,\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0&quot;Nested property in path '&quot;\u00a0+ propertyName +\u00a0&quot;' does not exist&quot;, ex);\n\u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u5c06\u7ed9\u5b9a\u7684\u5c5e\u6027\u540d\u79f0\u89e3\u6790\u4e3a\u76f8\u5e94\u7684\u5c5e\u6027\u540d\u79f0\u4ee4\u724c\uff0c\u5982\u679c\u6ca1\u6709[]\uff0c\u5219tokens\u4e2d\u7684keys\u4e3a\u7a7a\uff0c\u4e14actualName\u3001canonicalName\u90fd\u7b49\u4e8e propertyName\u00a0\n\u00a0 \u00a0 tokens = getPropertyNameTokens(getFinalPath(nestedPa, propertyName));\n\u00a0 \u00a0\u00a0if\u00a0(nestedPa ==\u00a0this) {\n\u00a0 \u00a0 \u00a0 pv.getOriginalPropertyValue().resolvedTokens = tokens;\n\u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u8bbe\u7f6e\u5c5e\u6027\n\u00a0 \u00a0 nestedPa.setPropertyValue(tokens, pv);\n\u00a0 }\n\u00a0\u00a0else\u00a0{\n\u00a0 \u00a0 \u00a0 \u00a0\/\/ \u8bbe\u7f6e\u5c5e\u6027\n\u00a0 \u00a0 setPropertyValue(tokens, pv);\n\u00a0 }\n}\n<\/code><\/pre>\n<p>\u5206\u6790setPropertyValue(tokens, pv)\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u662f\u7528\u6765\u533a\u5206\u6570\u7ec4\u7c7b\u578b\u8ddf\u975e\u6570\u7ec4\u7c7b\u578b\u7684\uff0c\u5927\u90e8\u5206\u5c5e\u6027\u90fd\u662f\u975e\u6570\u7ec4\u7c7b\u578b\uff0c\u6211\u4eec\u5206\u6790\u975e\u6570\u7ec4\u7c7b\u578b\u65b9\u6cd5\u3002<\/p>\n<pre><code>protected\u00a0void\u00a0setPropertyValue(PropertyTokenHolder tokens, PropertyValue pv)\u00a0throws\u00a0BeansException {\n\u00a0 \u00a0\u00a0\/\/ \u5982\u679c\u5c5e\u6027\u4e2d\u5b58\u5728[]\uff0c\u8bf4\u660e\u662f\u6570\u7ec4\uff0c\u5219\u8fdb\u5165\u8be5\u65b9\u6cd5\n\u00a0\u00a0if\u00a0(tokens.keys !=\u00a0null) {\n\u00a0 \u00a0 processKeyedProperty(tokens, pv);\n\u00a0 }\n\u00a0\u00a0else\u00a0{\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u5927\u90e8\u5206\u90fd\u8d70\u8fd9\u4e2a\u65b9\u6cd5\n\u00a0 \u00a0 processLocalProperty(tokens, pv);\n\u00a0 }\n}\n<\/code><\/pre>\n<p>processLocalProperty\u65b9\u6cd5\u7684\u4f5c\u7528\u5c31\u662f\u83b7\u53d6\u5c5e\u6027\u503c\uff0c\u5229\u7528\u53cd\u5c04\u5b8c\u6210\u5c5e\u6027\u6ce8\u5165\u3002<\/p>\n<pre><code>private\u00a0void\u00a0processLocalProperty(PropertyTokenHolder tokens, PropertyValue pv){\n\u00a0 \u00a0\u00a0\/\/ \u83b7\u53d6\u5c5e\u6027\u5bf9\u5e94\u7684 PropertyHandler\n\u00a0\u00a0PropertyHandler\u00a0ph\u00a0=\u00a0getLocalPropertyHandler(tokens.actualName);\n\u00a0 \u00a0\u00a0\/\/ \u5982\u679c\u4e0d\u5b58\u5728\u5bf9\u5e94\u7684handler \u6216\u8005 \u5c5e\u6027\u662f\u4e0d\u53ef\u5199\u7684\uff08\u6ca1\u6709setter\u65b9\u6cd5\uff09\n\u00a0\u00a0if\u00a0(ph ==\u00a0null\u00a0|| !ph.isWritable()) {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u5982\u679c\u5c5e\u6027\u662foptional\u7c7b\u578b\uff0c\u5219\u76f4\u63a5\u8fd4\u56de\n\u00a0 \u00a0\u00a0if\u00a0(pv.isOptional()) {\n\u00a0 \u00a0 \u00a0\u00a0if\u00a0(logger.isDebugEnabled()) {\n\u00a0 \u00a0 \u00a0 \u00a0 logger.debug(&quot;Ignoring optional value for property '&quot;\u00a0+ tokens.actualName +\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0&quot;' - property not found on bean class [&quot;\u00a0+ getRootClass().getName() +\u00a0&quot;]&quot;);\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0\u00a0return;\n\u00a0 \u00a0 }\n\u00a0 \u00a0\u00a0else\u00a0{\n\u00a0 \u00a0 \u00a0\u00a0\/\/ \u5176\u4ed6\u60c5\u51b5\u5219\u629b\u51fa\u4e0d\u53ef\u5199\u5c5e\u6027\u5f02\u5e38\uff0c\u5360\u7528CPU\u8f83\u591a\u7684\u65b9\u6cd5\u7531\u6b64\u8fdb\u5165\n\u00a0 \u00a0 \u00a0\u00a0throw\u00a0createNotWritablePropertyException(tokens.canonicalName);\n\u00a0 \u00a0 }\n\u00a0 }\n\n\u00a0\u00a0Object\u00a0oldValue\u00a0=\u00a0null;\n\u00a0\u00a0try\u00a0{\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u83b7\u53d6\u5c5e\u6027\u503c\n\u00a0 \u00a0\u00a0Object\u00a0originalValue\u00a0=\u00a0pv.getValue();\n\u00a0 \u00a0\u00a0Object\u00a0valueToApply\u00a0=\u00a0originalValue;\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u5982\u679c\u9700\u8981\u8f6c\u6362\uff0c\u5219\u8fdb\u5165\u6b64\u5206\u652f\n\u00a0 \u00a0\u00a0if\u00a0(!Boolean.FALSE.equals(pv.conversionNecessary)) {\n\u00a0 \u00a0 \u00a0\u00a0\/\/ \u5982\u679c\u5df2\u7ecf\u5b8c\u6210\u7c7b\u578b\u8f6c\u6362\uff0c\u5219\u76f4\u63a5\u4f7f\u7528\n\u00a0 \u00a0 \u00a0\u00a0if\u00a0(pv.isConverted()) {\n\u00a0 \u00a0 \u00a0 \u00a0 valueToApply = pv.getConvertedValue();\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0\u00a0else\u00a0{\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u5982\u679c\u9700\u8981\u8bfb\u53d6\u65e7\u503c\uff0c\u9ed8\u8ba4\u662ffalse &amp;&amp; \u503c\u53ef\u8bfb\uff08\u6709getter\u65b9\u6cd5\uff09\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0if\u00a0(isExtractOldValueForEditor() &amp;&amp; ph.isReadable()) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0try\u00a0{\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 oldValue = ph.getValue();\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0catch\u00a0(Exception ex) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0if\u00a0(ex\u00a0instanceof\u00a0PrivilegedActionException) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ex = ((PrivilegedActionException) ex).getException();\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0if\u00a0(logger.isDebugEnabled()) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 logger.debug(&quot;Could not read previous value of property '&quot;\u00a0+\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0this.nestedPath + tokens.canonicalName +\u00a0&quot;'&quot;, ex);\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u7c7b\u578b\u8f6c\u6362\n\u00a0 \u00a0 \u00a0 \u00a0 valueToApply = convertForProperty(\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 tokens.canonicalName, oldValue, originalValue, ph.toTypeDescriptor());\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 pv.getOriginalPropertyValue().conversionNecessary = (valueToApply != originalValue);\n\u00a0 \u00a0 }\n\u00a0 \u00a0\u00a0\/\/ \u5b8c\u6210\u5c5e\u6027\u6ce8\u5165\n\u00a0 \u00a0 ph.setValue(this.wrappedObject, valueToApply);\n\u00a0 }\n\u00a0\u00a0catch\u00a0(TypeMismatchException ex) {\n\u00a0 \u00a0\u00a0throw\u00a0ex;\n\u00a0 }\n\u00a0\u00a0catch\u00a0(InvocationTargetException ex) {\n\u00a0 \u00a0\u00a0PropertyChangeEvent\u00a0propertyChangeEvent\u00a0=\u00a0new\u00a0PropertyChangeEvent(\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0this.rootObject,\u00a0this.nestedPath + tokens.canonicalName, oldValue, pv.getValue());\n\u00a0 \u00a0\u00a0if\u00a0(ex.getTargetException()\u00a0instanceof\u00a0ClassCastException) {\n\u00a0 \u00a0 \u00a0 thrownew\u00a0TypeMismatchException(propertyChangeEvent, ph.getPropertyType(), ex.getTargetException());\n\u00a0 \u00a0 }\n\u00a0 \u00a0\u00a0else\u00a0{\n\u00a0 \u00a0 \u00a0\u00a0Throwable\u00a0cause\u00a0=\u00a0ex.getTargetException();\n\u00a0 \u00a0 \u00a0\u00a0if\u00a0(cause\u00a0instanceof\u00a0UndeclaredThrowableException) {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ May happen e.g. with Groovy-generated methods\n\u00a0 \u00a0 \u00a0 \u00a0 cause = cause.getCause();\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 thrownew\u00a0MethodInvocationException(propertyChangeEvent, cause);\n\u00a0 \u00a0 }\n\u00a0 }\n\u00a0\u00a0catch\u00a0(Exception ex) {\n\u00a0 \u00a0\u00a0PropertyChangeEvent\u00a0pce\u00a0=\u00a0new\u00a0PropertyChangeEvent(\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0this.rootObject,\u00a0this.nestedPath + tokens.canonicalName, oldValue, pv.getValue());\n\u00a0 \u00a0 thrownew\u00a0MethodInvocationException(pce, ex);\n\u00a0 }\n}\n<\/code><\/pre>\n<p>\u5728\u8be5\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u6ce8\u610f\u5230\u5806\u6808\u4fe1\u606f\u4e2dcreateNotWritablePropertyException\u65b9\u6cd5\u7684\u8c03\u7528\u3002\u5b9e\u9645\u4e0acalculateStringDistance\u65b9\u6cd5\u7684\u9ad8CPU\u6d88\u8017\u6b63\u662f\u7531\u6b64\u5f15\u53d1\u7684\u3002\u5f53\u629b\u51fa\u4e0d\u53ef\u5199\u5c5e\u6027\u5f02\u5e38\u65f6\uff0c\u7cfb\u7edf\u4f1a\u8ba1\u7b97\u5b57\u7b26\u4e32\u7684\u76f8\u4f3c\u5ea6\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u4e3a\u4e86\u5411\u7528\u6237\u63d0\u4f9b\u66f4\u53cb\u597d\u7684\u63d0\u793a\uff0c\u5e2e\u52a9\u4ed6\u4eec\u8bc6\u522b\u54ea\u4e9b\u5c5e\u6027\u4e0e\u5f53\u524d\u5c5e\u6027\u76f8\u4f3c\uff0c\u4ece\u800c\u5224\u65ad\u662f\u5426\u5728\u4f20\u9012\u53c2\u6570\u65f6\u51fa\u73b0\u4e86\u9519\u8bef\u3002<\/p>\n<p>Spring\u8fd9\u79cd\u8bbe\u8ba1\u4e0d\u4ec5\u63d0\u5347\u4e86\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u964d\u4f4e\u4e86\u56e0\u53c2\u6570\u9519\u8bef\u800c\u5bfc\u81f4\u7684\u8c03\u8bd5\u96be\u5ea6\u3002\u901a\u8fc7\u63d0\u4f9b\u76f8\u4f3c\u5c5e\u6027\u7684\u5efa\u8bae\uff0c\u7528\u6237\u80fd\u591f\u66f4\u5feb\u901f\u5730\u53d1\u73b0\u5e76\u7ea0\u6b63\u8f93\u5165\u9519\u8bef\uff0c\u786e\u4fdd\u8bf7\u6c42\u7684\u6b63\u786e\u6027\u3002\u4ee5\u4e0b\u4e3a\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\u7684\u90e8\u5206\u63d0\u793a\uff1a<\/p>\n<pre><code>Bean property\u00a0'questionValidatorInterface'\u00a0is not writable or has an invalid\u00a0setter\u00a0method. Does the parameter type of the\u00a0setter\u00a0match the\u00a0return\u00a0type of the\u00a0getter?\nbean property\u00a0'users'\u00a0is not writable or has an invalid\u00a0setter\u00a0method. did you mean\u00a0'user'?\n<\/code><\/pre>\n<h4>5.1.3 calculateStringDistance\u6d41\u7a0b\u603b\u7ed3<\/h4>\n<p>\u7ed3\u5408Spring MVC\u89e3\u6790HTTP\u7684\u8bf7\u6c42\u6d41\u7a0b\uff0ccalculateStringDistance\u65b9\u6cd5\u7684\u8fdb\u5165\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060412\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u89e3\u6790\u53c2\u6570\u6d41\u7a0b<\/p>\n<p>Spring MVC\u5728\u89e3\u6790HTTP\u8bf7\u6c42\u53c2\u6570\u65f6\u4f1a\u627e\u5230\u5bf9\u5e94\u7684\u53c2\u6570\u89e3\u6790\u5668\uff0c\u56e0\u4e3a\u6211\u4eec\u7684\u9879\u76ee\u4e2d\u5927\u90e8\u5206\u90fd\u662f\u81ea\u5b9a\u4e49\u7684\u590d\u6742\u5bf9\u8c61\uff0c\u56e0\u6b64\u91c7\u7528\u7684\u53c2\u6570\u89e3\u6790\u5668\u4e3aServletModelAttributeMethodProcessor\u3002\u8be5\u89e3\u6790\u5668\u5728\u6570\u636e\u7ed1\u5b9a\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u5faa\u73af\u904d\u5386\u6bcf\u4e2a\u53c2\u6570\uff0c\u901a\u8fc7\u53cd\u5c04\u5b8c\u6210\u5c5e\u6027\u6ce8\u5165\u3002\u4f46\u662f\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u590d\u6742\u5bf9\u8c61\u5728\u67d0\u4e9b\u63a5\u53e3\u4e0b\uff0c\u5b9a\u4e49\u7684\u5c5e\u6027\u4e0d\u5408\u7406\uff0c\u5bfc\u81f4\u629b\u51facreateNotWritablePropertyException\u5f02\u5e38\u3002<\/p>\n<p>\u6211\u4eec\u6df1\u5165\u5206\u6790\u4e00\u4e0b\u6e90\u7801\uff0c\u770b\u770b\u600e\u6837\u907f\u514d\u629b\u51facreateNotWritablePropertyException\u5f02\u5e38\u3002<\/p>\n<p>\u6839\u636e\u6e90\u7801\uff0c\u6211\u4eec\u53d1\u73b0\u629b\u51fa\u4e0d\u53ef\u5199\u5c5e\u6027\u5f02\u5e38\u7684\u6761\u4ef6\u662f\uff08\u5c5e\u6027\u4e0d\u5b58\u5728\u5bf9\u5e94\u7684handler \u6216\u8005 \u5c5e\u6027\u4e0d\u53ef\u5199\uff09\u5e76\u4e14\u5c5e\u6027\u4e0d\u662foptional\u7c7b\u578b\uff0c\u53ea\u8981\u6211\u4eec\u4fdd\u8bc1\u4e0d\u6ee1\u8db3\u8fd9\u4e2a\u6761\u4ef6\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u6709\u6548\u907f\u514d\u629b\u51fa\u8be5\u5f02\u5e38\u3002<\/p>\n<p>\u8bf4\u660e\u4e00\u4e0b\u8fd9\u4e09\u4e2a\u6761\u4ef6\uff1a<\/p>\n<ul>\n<li>\u5c5e\u6027\u4e0d\u5b58\u5728\u5bf9\u5e94\u7684handler \u5373 request\u4e2d\u4e0d\u5b58\u5728\u8be5\u5c5e\u6027\u3002\u6bd4\u5982\u8bf7\u6c42\u53c2\u6570\u4e2d\u5e26version\u5b57\u6bb5\uff0c\u4f46\u662f\u670d\u52a1\u7aef\u5728\u63a5\u53d7request\u4e2d\u5e76\u672a\u5b9a\u4e49version\u5b57\u6bb5\uff0c\u90a3\u4e48\u6b64\u5904ph == null\u5224\u65ad\u6761\u4ef6\u5c31\u6210\u7acb<\/li>\n<li>\u5c5e\u6027\u4e0d\u53ef\u5199\uff0c\u5373\u5c5e\u6027\u6ca1\u6709\u5bf9\u5e94\u7684setter\u65b9\u6cd5<\/li>\n<li>\u5c5e\u6027\u662foptional\u7c7b\u578b\uff0c\u5373\u5c5e\u6027\u7684\u6570\u636e\u7c7b\u578b\u662fOptional\u7c7b\u578b<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u67e5\u770b\u4e1a\u52a1\u4fa7\u7684\u4ee3\u7801\uff0c\u6211\u4eec\u53d1\u73b0\u8bf7\u6c42\uff08request\uff09\u4e2d\u7684\u6240\u6709\u5c5e\u6027\u90fd\u5df2\u7ecf\u5b9a\u4e49\u4e86\u76f8\u5e94\u7684 setter \u65b9\u6cd5\uff0c\u800c\u4e14\u4e0d\u5b58\u5728optional\u7c7b\u578b\u7684\u5c5e\u6027\u3002\u56e0\u6b64\u6211\u4eec\u53ea\u9700\u8981\u5173\u6ce8\u8bf7\u6c42\u4e2d\u662f\u5426\u5b58\u5728\u672a\u5b9a\u4e49\u7684\u5c5e\u6027\u3002<\/p>\n<h4>5.1.4 \u6392\u67e5\u5927\u6d41\u91cf\u53ca\u6838\u5fc3\u63a5\u53e3\u53c2\u6570<\/h4>\n<p>\u7531\u4e8e\u670d\u52a1\u63d0\u4f9b\u7684\u63a5\u53e3\u975e\u5e38\u591a\uff0c\u56e0\u6b64\u4ec5\u6392\u67e5\u6d41\u91cf\u8f83\u9ad8\u548c\u6838\u5fc3\u7684\u63a5\u53e3\u3002\u7ecf\u8fc7\u5206\u6790\uff0c\u6211\u4eec\u53d1\u73b0\u51e0\u4e4e\u6240\u6709\u63a5\u53e3\u90fd\u5b58\u5728\u672a\u5b9a\u4e49\u7684\u5c5e\u6027\u3002<\/p>\n<p>\u8fd9\u4e3b\u8981\u662f\u56e0\u4e3a\u5ba2\u6237\u7aef\u5f88\u591a\u53c2\u6570\u90fd\u662f\u516c\u53c2\uff0c\u5728\u4f20\u53c2\u65f6\u4f1a\u5c06\u8fd9\u4e9b\u516c\u53c2\u5168\u90e8\u900f\u4f20\u7ed9\u670d\u52a1\u7aef\uff0c\u4f46\u662f\u670d\u52a1\u7aef\u5e76\u4e0d\u9700\u8981\u5904\u7406\u6240\u6709\u7684\u53c2\u6570\uff0c\u56e0\u6b64\u6ca1\u6709\u5728request\u4e2d\u5b9a\u4e49\u3002\u7279\u522b\u5907\u6ce8\uff1a\u63a5\u53e3\u82e5\u672a\u5b9a\u4e49\u8bf7\u6c42\u53c2\u6570\u63a5\u6536\uff0c\u5219\u4e0d\u4f1a\u8d70\u4e0a\u8ff0\u6d41\u7a0b\u3002<\/p>\n<h4>5.1.5 \u89e3\u51b3\u65b9\u6848<\/h4>\n<p>\u65e2\u7136\u5df2\u7ecf\u660e\u786e\u95ee\u9898\u7684\u6839\u6e90\u662f\u8bf7\u6c42\u4e2d\u5b58\u5728\u672a\u5b9a\u4e49\u7684\u5c5e\u6027\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u9488\u5bf9\u8fd9\u4e00\u60c5\u51b5\u8fdb\u884c\u4f18\u5316\u3002\u65b9\u6848\u4e3b\u8981\u6709\u4e24\u4e2a\uff1a<\/p>\n<blockquote>\n<ol>\n<li>\u5728\u5e95\u5c42\u8bf7\u6c42\u4e2d\u52a0\u5165\u5ba2\u6237\u7aef\u516c\u53c2\uff1a\u5bf9\u6240\u6709\u516c\u53c2\u8fdb\u884c\u63a5\u6536\uff0c\u786e\u4fdd\u5b83\u4eec\u80fd\u591f\u88ab\u6b63\u786e\u5904\u7406\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u53c2\u6570\u63a5\u6536\u5c06\u4f1a\u6d89\u53ca\u5c5e\u6027\u6ce8\u5165\uff0c\u800c\u5c5e\u6027\u6ce8\u5165\u662f\u901a\u8fc7\u53cd\u5c04\u673a\u5236\u5b9e\u73b0\u7684\u3002\u8fd9\u4e00\u8fc7\u7a0b\u53ef\u80fd\u5bf9CPU\u548c\u63a5\u53e3\u6027\u80fd\u4ea7\u751f\u5f71\u54cd\uff0c\u56e0\u6b64\u6211\u4eec\u4e5f\u9700\u8981\u8fdb\u884c\u5b9e\u9a8c\uff0c\u4ee5\u8bc4\u4f30\u8fd9\u4e9b\u53c2\u6570\u89e3\u6790\u7684\u5b9e\u9645\u6548\u679c\u3002<\/li>\n<li>\u5728filter\u5c42\u9488\u5bf9\u63a5\u53e3\u53bb\u9664\u76f8\u5173\u5b57\u6bb5\uff1a\u901a\u8fc7\u5728\u8fc7\u6ee4\u5668\u5c42\u9762\u8fc7\u6ee4\u6389\u4e0d\u5fc5\u8981\u7684\u5b57\u6bb5\uff0c\u907f\u514d\u63a5\u53e3\u4e2d\u51fa\u73b0\u672a\u5b9a\u4e49\u7684\u5c5e\u6027\u3002<\/li>\n<\/ol>\n<\/blockquote>\n<p>\u6700\u7ec8\u6211\u4eec\u6df7\u5408\u4e24\u79cd\u65b9\u6848\uff1a\u5bf9\u4e8e\u5927\u90e8\u5206\u516c\u5171\u53c2\u6570\uff0c\u5b9a\u4e49\u5230\u5e95\u5c42request\u4e2d\uff1b\u5bf9\u4e8e\u975e\u516c\u5171\u53c2\u6570\uff0c\u9488\u5bf9\u63a5\u53e3\u8fdb\u884c\u79fb\u9664\u3002<\/p>\n<p>\u6211\u4eec\u9488\u5bf9\u5927\u6d41\u91cf\u63a5\u53e3\u53ca\u6838\u5fc3\u63a5\u53e3\u8fdb\u884c\u4e86\u4f18\u5316\uff0c\u4f18\u5316\u540e\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p>\u7ed3\u8bba\uff1a\u6574\u4f53\u6548\u679c\u663e\u8457\uff0c\u4f46\u4ecd\u5b58\u5728\u4e00\u4e9b\u4e0d\u8db3\u4e4b\u5904\u3002<\/p>\n<ul>\n<li><strong>CPU\u4f7f\u7528\u60c5\u51b5<\/strong>\uff1a\u5728\u9ad8\u5cf0\u671f\u91cd\u542f\u5e94\u7528\u65f6\uff0cCPU\u7684\u7a81\u53d1\u60c5\u51b5\u660e\u663e\u51cf\u5f31\uff0c\u6301\u7eed\u65f6\u95f4\u4ece5\u5206\u949f\u7f29\u77ed\u81f31\u5206\u949f\u3002\u540c\u65f6CPU\u548cRunnable\u7ebf\u7a0b\u6570\u4ecd\u4f1a\u51fa\u73b0\u5c0f\u5e45\u6ce2\u52a8\uff0c\u4f46Runnable\u7ebf\u7a0b\u6570\u7684\u6ce2\u52a8\u6301\u7eed\u65f6\u95f4\u5df2\u4ece6\u5206\u949f\u7f29\u51cf\u81f340\u79d2\uff0c\u6ce2\u52a8\u5cf0\u503c\u4e5f\u7531600\u964d\u4f4e\u81f3280\u3002<\/li>\n<li><strong>\u63a5\u53e3\u6027\u80fd<\/strong>\uff1a\u63a5\u53e3\u7684P95\u548cP99\u8017\u65f6\u5747\u6709\u6240\u964d\u4f4e\uff0c\u5176\u4e2dP95\u5cf0\u503c\u4ece53\u79d2\u964d\u81f33.4\u79d2\uff0cP99\u5cf0\u503c\u4ece1\u520650\u79d2\u964d\u81f350\u79d2\u3002\u6b64\u5916\uff0c\u54cd\u5e94\u65f6\u95f4\u8f83\u957f\u7684\u65f6\u95f4\u6bb5\u4e5f\u5f97\u5230\u4e86\u7f29\u77ed\uff0c\u6301\u7eed\u65f6\u95f4\u4ece7\u5206\u949f\u51cf\u5c11\u5230\u4e0d\u52302\u5206\u949f\u3002<\/li>\n<li><strong>\u53d1\u7248\u53ca\u65e5\u5e38\u8fd0\u884c<\/strong>\uff1a\u5728\u53d1\u7248\u671f\u95f4\u53ca\u65e5\u5e38\u8fd0\u884c\u4e2d\uff0cCPU\u5cf0\u503c\u666e\u904d\u964d\u4f4e\u3002\u4e0e\u524d1\u5929\u548c\u524d7\u5929\u7684\u5e73\u5747CPU\u4f7f\u7528\u7387\u76f8\u6bd4\uff0c\u6700\u5927\u548c\u6700\u5c0f\u4f7f\u7528\u7387\u5747\u6709\u6240\u4e0b\u964d\uff0c\u5e45\u5ea6\u660e\u663e\u3002<\/li>\n<\/ul>\n<p><strong>\u2460 \u542f\u52a8\u540eCPU\u4f7f\u7528\u7387\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060413\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>CPU\u4f7f\u7528\u7387<\/p>\n<p><strong>\u2461 \u7ebf\u7a0b\u6570\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060414\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Runnable\u7ebf\u7a0b\u6570<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060415\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Blocked\u7ebf\u7a0b\u6570<\/p>\n<p><strong>\u2462 \u63a5\u53e3\u54cd\u5e94\u65f6\u95f4\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060416\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u63a5\u53e3\u54cd\u5e94\u65f6\u95f4<\/p>\n<p><strong>\u2463 \u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u540e\uff0cCPU\u4f7f\u7528\u7387\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060417\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>CPU\u4f7f\u7528\u7387<\/p>\n<h3>5.2 \u4f18\u5316\u540e\u518d\u6b21\u5206\u6790CPU\u706b\u7130\u56fe<\/h3>\n<p>\u4f18\u5316\u540e\u6548\u679c\u867d\u7136\u597d\u4e86\u5f88\u591a\uff0c\u4f46\u662fCPU\u548cRunnable\u7ebf\u7a0b\u6570\u4ecd\u4f1a\u51fa\u73b0\u5c0f\u5e45\u6ce2\u52a8\uff0c\u63a5\u53e3\u7684\u54cd\u5e94\u65f6\u95f4\u57281\u5206\u949f\u5185\u4ecd\u6709\u4e0a\u6da8\u3002\u8fd9\u662f\u6211\u4eec\u63a5\u4e0b\u6765\u8981\u7ee7\u7eed\u4f18\u5316\u7684\u76ee\u6807\u3002<\/p>\n<h4>5.2.1 \u7f16\u8bd1\u9636\u6bb5\u6d88\u8017CPU\u5360\u6bd4\u9ad8<\/h4>\n<p>\u518d\u6b21\u4f7f\u7528arthas\u8fdb\u884c\u76d1\u6d4b\uff0c\u67e5\u770b\u6b63\u5e38\u60c5\u51b5\u4e0e\u542f\u52a8\u540e\uff08\u5f02\u5e38\u60c5\u51b5\uff09\u7684CPU\u6d88\u8017\u60c5\u51b5\uff0c\u6211\u4eec\u53ef\u4ee5\u89c2\u5bdf\u5230\uff1a<\/p>\n<ul>\n<li>runWoker\u90e8\u5206\uff1a<\/li>\n<\/ul>\n<p>\u8be5\u90e8\u5206\u7684 CPU \u5360\u7528\u6bd4\u4f8b\u6b63\u5e38\uff0c\u4e0e\u5e73\u65f6\u7684\u8868\u73b0\u4e00\u81f4\uff0c\u672a\u89c1\u5f02\u5e38\u6ce2\u52a8\u3002<\/p>\n<ul>\n<li>\u7f16\u8bd1\u76f8\u5173\u7684CPU\u5360\u7528\uff1a<\/li>\n<\/ul>\n<p>CompileBroker::invoke\/_compiler\/_on\/_method(CompileTask<em>) \u5360\u7528CPU\u8f83\u5927\uff0c\u7279\u522b\u662fC2Compiler::compile\/_method(ciEnv<\/em>, ciMethod*, int)\u7684\u5360\u6bd4\u663e\u8457<\/p>\n<p>\u7531\u6b64\u6211\u4eec\u5f97\u51fa\u7ed3\u8bba\uff1a\u7f16\u8bd1\u9636\u6bb5\u7684 CPU \u6d88\u8017\u5360\u6bd4\u5f02\u5e38\uff0c\u53ef\u80fd\u662f\u5bfc\u81f4CPU\u8d1f\u8f7d\u7a81\u523a\u7684\u91cd\u8981\u56e0\u7d20\u3002<\/p>\n<p><strong>\u2460 \u5f02\u5e38\u60c5\u51b5\u4e0bCPU\u706b\u7130\u56fe\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060418\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u5f02\u5e38CPU\u706b\u7130\u56fe<\/p>\n<p><strong>\u2461 \u6b63\u5e38\u60c5\u51b5\u4e0bCPU\u706b\u7130\u56fe\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060419\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u6b63\u5e38CPU\u706b\u7130\u56fe<\/p>\n<h4>5.2.2 \u7528arthas\u6362\u4e2a\u89d2\u5ea6\u9a8c\u8bc1<\/h4>\n<p>CPU \u706b\u7130\u56fe\u662f\u57fa\u4e8e\u542f\u52a8\u540e 3 \u5206\u949f\u5185\u7684\u7efc\u5408\u6570\u636e\u91c7\u96c6\u800c\u751f\u6210\u7684\uff0c\u867d\u7136\u80fd\u591f\u63d0\u4f9b\u6574\u4f53\u7684 CPU \u4f7f\u7528\u60c5\u51b5\uff0c\u4f46\u65e0\u6cd5\u53cd\u6620 CPU \u7684\u5b9e\u65f6\u53d8\u5316\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u66f4\u51c6\u786e\u5730\u9a8c\u8bc1\u7f16\u8bd1\u9636\u6bb5\u662f\u5426\u786e\u5b9e\u6d88\u8017\u4e86 CPU\uff0c\u6211\u4eec\u9700\u8981\u767b\u5f55\u5230\u673a\u5668\u4e0a\uff0c\u4f7f\u7528 Arthas \u8fdb\u884c\u5b9e\u65f6\u76d1\u6d4b\u3002<\/p>\n<p>\u673a\u5668\u542f\u52a8\u540e\uff0c\u8fd0\u884cdashboard\u547d\u4ee4\uff0c\u91cd\u70b9\u5173\u6ce8\u5c4f\u5e55\u4e0a\u65b9\u7684\u8fdb\u7a0b\u4fe1\u606f\uff0c\u4ee5\u8bc6\u522b\u54ea\u4e9b\u7ebf\u7a0b\u5360\u636e\u4e86\u8f83\u9ad8\u7684CPU\u8d44\u6e90\uff0c\u4ee5\u4e0b\u4e3a\u5176\u4e2d\u4e00\u6b21\u6ce2\u52a8\u7684\u622a\u56fe\uff0c\u524d\u51e0\u6b21\u6ce2\u52a8CPU\u5360\u6bd4\u90fd\u5dee\u4e0d\u591a\uff1a<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060420\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>dashboard\u547d\u4ee4<\/p>\n<p>\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c CompilerThread \u7684\u4e09\u4e2a\u7ebf\u7a0b\u5360\u7528\u4e86\u8f83\u9ad8\u7684 CPU \u8d44\u6e90\uff0c\u5c24\u5176\u662f C2 CompilerThread \u7684\u5360\u6bd4\u660e\u663e\uff0c\u8fd9\u4e0e\u4e4b\u524d\u901a\u8fc7\u706b\u7130\u56fe\u6240\u53cd\u6620\u7684\u60c5\u51b5\u4e00\u81f4\u3002<\/p>\n<h4>5.2.3 CompilerThread\u662f\u4ec0\u4e48<\/h4>\n<p>C1 C2 CompilerThread \u662f Java HotSpot \u865a\u62df\u673a\u4e2d\u7684\u4e24\u4e2a\u5373\u65f6\u7f16\u8bd1\u5668\uff0c\u4e3b\u8981\u4f5c\u7528\u662f\u5c06 Java \u5b57\u8282\u7801\u5728\u8fd0\u884c\u65f6\u7f16\u8bd1\u6210\u672c\u5730\u673a\u5668\u7801\uff0c\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6267\u884c\u6548\u7387\u3002<\/p>\n<ul>\n<li>C1 Compiler\uff08\u4e5f\u79f0\u4e3a\u5ba2\u6237\u7aef\u7f16\u8bd1\u5668\uff09\uff0c\u4e3b\u8981\u7528\u4e8e\u5feb\u901f\u7f16\u8bd1\uff0c\u4f18\u5316\u8f83\u5c11\uff0c\u9002\u5408\u9700\u8981\u5feb\u901f\u542f\u52a8\u7684\u5e94\u7528\u3002\u5b83\u7684\u7f16\u8bd1\u901f\u5ea6\u8f83\u5feb\uff0c\u4f46\u751f\u6210\u7684\u673a\u5668\u7801\u6267\u884c\u6548\u7387\u76f8\u5bf9\u8f83\u4f4e\u3002<\/li>\n<li>C2 Compiler\uff08\u4e5f\u79f0\u4e3a\u670d\u52a1\u7aef\u7f16\u8bd1\u5668\uff09\uff0c\u4e3b\u8981\u7528\u4e8e\u9ad8\u6027\u80fd\u7684\u7f16\u8bd1\uff0c\u4f18\u5316\u7a0b\u5ea6\u8f83\u9ad8\uff0c\u9002\u5408\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u5e94\u7528\u3002C2 \u7f16\u8bd1\u5668\u4f1a\u82b1\u8d39\u66f4\u591a\u65f6\u95f4\u8fdb\u884c\u4f18\u5316\uff0c\u4ee5\u751f\u6210\u66f4\u9ad8\u6548\u7684\u673a\u5668\u7801\uff0c\u9002\u5408\u5bf9\u6027\u80fd\u8981\u6c42\u8f83\u9ad8\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n<p>\u5728HotSpot\u865a\u62df\u673a\u4e2d\uff0cJava\u7a0b\u5e8f\u6700\u521d\u90fd\u662f\u901a\u8fc7\u89e3\u91ca\u5668\uff08Interpreter\uff09\u8fdb\u884c\u89e3\u91ca\u6267\u884c\u7684\uff0c\u89e3\u91ca\u5668\u7684\u4f18\u70b9\u662f\u542f\u52a8\u5feb\uff0c\u7701\u53bb\u7f16\u8bd1\u7684\u65f6\u95f4\uff0c\u80fd\u591f\u5feb\u901f\u8fd0\u884c\u4ee3\u7801\u3002\u4f46\u968f\u7740\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u67d0\u4e9b\u65b9\u6cd5\u6216\u4ee3\u7801\u5757\u53ef\u80fd\u4f1a\u88ab\u591a\u6b21\u8c03\u7528\uff0c\u8fd9\u4e9b\u88ab\u9891\u7e41\u8c03\u7528\u7684\u4ee3\u7801\u88ab\u79f0\u4e3a\u201c\u70ed\u70b9\u4ee3\u7801\u201d\uff08Hot Spot Code\uff09\u3002\u5f53\u865a\u62df\u673a\u8bc6\u522b\u5230\u70ed\u70b9\u4ee3\u7801\u65f6\uff0c\u5b83\u4f1a\u542f\u52a8 JIT \u7f16\u8bd1\u5668\uff08C1 \u6216 C2\uff09\u5c06\u8fd9\u4e9b\u4ee3\u7801\u7f16\u8bd1\u6210\u672c\u5730\u673a\u5668\u7801\uff0c\u4ee5\u63d0\u9ad8\u6267\u884c\u6548\u7387\u3002<\/p>\n<p>HotSpot\u865a\u62df\u673a\u662f\u89e3\u91ca\u5668\u4e0e\u5373\u65f6\u7f16\u8bd1\u5668\u5e76\u5b58\u7684\u67b6\u6784\uff0c\u4e24\u8005\u7ecf\u5e38\u662f\u76f8\u8f85\u76f8\u6210\u5730\u914d\u5408\u5de5\u4f5c\u3002\u7531\u4e8e\u5373\u65f6\u7f16\u8bd1\u5668\u7f16\u8bd1\u672c\u5730\u4ee3\u7801\u9700\u8981\u5360\u7528\u7a0b\u5e8f\u8fd0\u884c\u65f6\u95f4\uff0c\u7f16\u8bd1\u51fa\u4f18\u5316\u7a0b\u5ea6\u66f4\u9ad8\u7684\u4ee3\u7801\u6240\u9700\u7684\u65f6\u95f4\u4e5f\u4f1a\u76f8\u5e94\u589e\u52a0\u3002\u6b64\u5916\u4e3a\u4e86\u5b9e\u73b0\u66f4\u9ad8\u7684\u4f18\u5316\uff0c\u89e3\u91ca\u5668\u9700\u8981\u4e3a\u7f16\u8bd1\u5668\u6536\u96c6\u6027\u80fd\u76d1\u63a7\u4fe1\u606f\uff0c\u8fd9\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u4e5f\u4f1a\u5f71\u54cd\u89e3\u91ca\u6267\u884c\u9636\u6bb5\u7684\u901f\u5ea6\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0c\u5e76\u5728\u7a0b\u5e8f\u542f\u52a8\u54cd\u5e94\u901f\u5ea6\u4e0e\u8fd0\u884c\u6548\u7387\u4e4b\u95f4\u8fbe\u5230\u6700\u4f73\u5e73\u8861\uff0cHotSpot \u865a\u62df\u673a\u5728\u5176\u7f16\u8bd1\u5b50\u7cfb\u7edf\u4e2d\u5f15\u5165\u4e86\u5206\u5c42\u7f16\u8bd1\u7684\u529f\u80fd\u3002\u901a\u8fc7\u8fd9\u4e00\u673a\u5236\uff0cHotSpot \u80fd\u591f\u6839\u636e\u4ee3\u7801\u7684\u6267\u884c\u9891\u7387\u548c\u6027\u80fd\u9700\u6c42\uff0c\u9010\u6b65\u5c06\u5b57\u8282\u7801\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\uff0c\u4ece\u800c\u5728\u4fdd\u8bc1\u5feb\u901f\u542f\u52a8\u7684\u540c\u65f6\uff0c\u4f18\u5316\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u4ee3\u7801\u6027\u80fd\u3002<\/p>\n<h4>5.2.4 \u89e3\u51b3\u65b9\u6848<\/h4>\n<p>\u622a\u6b62\u5230\u73b0\u5728\uff0c\u95ee\u9898\u7684\u539f\u56e0\u5c31\u53d8\u5f97\u5341\u5206\u6e05\u6670\u4e86\uff1a\u5f53\u6d41\u91cf\u6d8c\u5165\u65f6\uff0cHotSpot \u865a\u62df\u673a\u542f\u52a8\u4e86\u5206\u5c42\u7f16\u8bd1\u673a\u5236\uff0c\u671f\u95f4\u5927\u90e8\u5206\u4ee3\u7801\u8fc5\u901f\u8f6c\u53d8\u4e3a\u70ed\u70b9\u4ee3\u7801\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0cC2 \u7f16\u8bd1\u5668\u9700\u8981\u9891\u7e41\u5360\u7528 CPU \u8d44\u6e90\u8fdb\u884c\u7f16\u8bd1\uff0c\u5bfc\u81f4 CPU \u4f7f\u7528\u7387\u663e\u8457\u4e0a\u5347\u3002\u968f\u7740\u5927\u90e8\u5206\u70ed\u70b9\u4ee3\u7801\u7684\u4f18\u5316\u5b8c\u6210\uff0cC2 \u7f16\u8bd1\u5668\u5bf9 CPU \u7684\u5360\u7528\u5c06\u9010\u6e10\u51cf\u5c11\uff0cCPU \u4f7f\u7528\u7387\u4e5f\u4f1a\u968f\u4e4b\u4e0b\u964d\u3002\u8fd9\u4e00\u7f16\u8bd1\u8fc7\u7a0b\u7684\u6301\u7eed\u65f6\u95f4\u4e0e\u76d1\u63a7\u56fe\u4e0a\u7684 CPU \u6ce2\u52a8\u60c5\u51b5\u9ad8\u5ea6\u4e00\u81f4\u3002<\/p>\n<p>C1 \u548c C2 \u7f16\u8bd1\u5668\u867d\u7136\u63d0\u4f9b\u4e86\u5173\u95ed\u7684\u53c2\u6570\u9009\u9879\uff0c\u4f46\u5173\u95ed\u8fd9\u4e9b\u7f16\u8bd1\u5668\u65e0\u7591\u4f1a\u5bf9\u670d\u52a1\u7684\u8fd0\u884c\u6027\u80fd\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\u3002\u7f51\u7edc\u4e0a\u4e5f\u6709\u76f8\u5173\u5b9e\u9a8c\u6848\u4f8b\u8868\u660e\uff0c\u5bf9\u4e8e\u9700\u8981\u957f\u671f\u8fd0\u884c\u7684 Java \u540e\u7aef\u670d\u52a1\uff0c\u7981\u7528\u8fd9\u4e9b\u7f16\u8bd1\u5668\u5c06\u5bfc\u81f4\u6027\u80fd\u663e\u8457\u4e0b\u964d\u3002\u56e0\u6b64\u8fd9\u79cd\u5173\u95ed\u7f16\u8bd1\u5668\u7684\u65b9\u5f0f\u5e76\u4e0d\u503c\u5f97\u5c1d\u8bd5\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\u4e00\uff1a<\/strong><\/p>\n<p>\u5728\u524d\u6587\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u9a8c\u8bc1\u4e86\u6d41\u91cf\u9010\u6b65\u653e\u91cf\u5bf9\u673a\u5668\u7684\u5f71\u54cd\uff1a\u91c7\u7528\u7070\u5ea6\u53d1\u5e03\uff0c\u5bf9\u673a\u5668\u51e0\u4e4e\u6ca1\u4ec0\u4e48\u5f71\u54cd\uff0c\u5404\u9879\u6307\u6807\u8868\u73b0\u90fd\u5f88\u5e73\u7a33\u3002\u7531\u4e8e\u5386\u53f2\u539f\u56e0\uff0c\u6211\u4eec\u7684\u670d\u52a1\u5f53\u524d\u65e0\u6cd5\u652f\u6301\u7070\u5ea6\u53d1\u5e03\uff0c\u56e0\u6b64\u8fd8\u9700\u8981\u63a2\u7d22\u5176\u4ed6\u6709\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u6362\u4e2a\u89d2\u5ea6\u601d\u8003\uff1a\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u964d\u4f4e\u63a5\u53e3\u7684\u8bf7\u6c42 QPS\uff0c\u5e76\u5c06\u53d1\u7248\u65f6\u95f4\u56fa\u5b9a\u5728\u6bcf\u5929\u6d41\u91cf\u6700\u4f4e\u7684\u65f6\u6bb5\uff0c\u4ee5\u89c2\u5bdf\u5bf9\u670d\u52a1\u542f\u52a8\u7684\u5f71\u54cd\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u53ef\u4ee5\u4f18\u5148\u5173\u6ce8\u5927\u6d41\u91cf\u63a5\u53e3\uff0c\u5e76\u5c1d\u8bd5\u51cf\u5c11\u8fd9\u4e9b\u63a5\u53e3\u7684 QPS\u3002\u901a\u8fc7\u4f18\u5316\u63a5\u53e3\u8bf7\u6c42\u7684\u9891\u7387\uff0c\u6211\u4eec\u6216\u8bb8\u80fd\u591f\u5728\u53d1\u7248\u8fc7\u7a0b\u4e2d\u51cf\u8f7b\u5bf9\u7cfb\u7edf\u7684\u538b\u529b\u3002<\/p>\n<p>\u964d\u4f4e\u63a5\u53e3QPS\uff0c\u8c03\u6574\u91cd\u542f\u670d\u52a1\u7684\u65f6\u95f4\uff08\u975e\u9ad8\u5cf0\u671f\uff09\uff0c12:13:59 \u6062\u590d\u6d41\u91cf\u6210\u529f\uff0c\u5b9e\u9a8c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u6062\u590d\u6d41\u91cf\u540eCPU\u6700\u9ad8\u5cf0\u503c\u4e3a61.5%\uff08\u4f9d\u65e7\u6709\u5c0f\u7a81\u523a\uff0c\u4f46\u662f\u5bf9\u4e1a\u52a1\u65e0\u5f71\u54cd\uff09<\/li>\n<li>Runnable\u3001Blocked\u7ebf\u7a0b\u6570\u4e0d\u518d\u6709\u7a81\u523a<\/li>\n<li>\u63a5\u53e3\u54cd\u5e94\u65f6\u95f4\uff08RT\uff09\u4e5f\u6bd4\u8f83\u5e73\u7a33<\/li>\n<li>\u65e5\u5fd7\u4e0d\u518d\u544a\u8b66\uff0c\u65e0error\u9519\u8bef\u65e5\u5fd7<\/li>\n<\/ul>\n<p><strong>\u2460 CPU\u4f7f\u7528\u7387\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060421\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>CPU\u4f7f\u7528\u7387<\/p>\n<p><strong>\u2461 \u7ebf\u7a0b\u6307\u6807\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060422\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Runnable\u7ebf\u7a0b\u6570<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060423\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Blocked\u7ebf\u7a0b\u6570<\/p>\n<p><strong>\u2462 \u63a5\u53e3\u54cd\u5e94\u65f6\u95f4\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060424\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>\u63a5\u53e3\u54cd\u5e94\u65f6\u95f4<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\u4e8c\uff1a<\/strong><\/p>\n<p>\u65b9\u6848\u4e00\u867d\u7136\u80fd\u591f\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u7f13\u89e3\u95ee\u9898\uff0c\u4f46\u6cbb\u6807\u4e0d\u6cbb\u672c\u3002\u6b64\u5916\u6211\u4eec\u4e5f\u65e0\u6cd5\u56fa\u5b9a\u53d1\u7248\u65f6\u95f4\uff0c\u56e0\u6b64\u6700\u6709\u6548\u7684\u7b56\u7565\u662f\u8fdb\u884c\u9884\u70ed\u3002\u4e0e\u524d\u6587\u4e0d\u540c\u7684\u70b9\u5728\u4e8e\uff0c\u6b64\u5904\u662fJVM\u9884\u70ed\u3002<\/p>\n<p>\u65b9\u6848\u4e3a\uff1a\u5728\u7cfb\u7edf\u6210\u529f\u542f\u52a8\uff08\u76d1\u6d4bcheck.do\u8fd4\u56de\u6210\u529f\uff09\u540e\uff0c\u63a5\u5165\u7ebf\u4e0aHTTP\u6d41\u91cf\u4e4b\u524d\uff0c\u9488\u5bf9\u5927\u6d41\u91cf\u63a5\u53e3\u53ca\u6838\u5fc3\u63a5\u53e3\u8fdb\u884cHTTP\u63a5\u53e3\u8c03\u7528\uff0c\u9891\u63a7\u6b21\u6570\u4e3a\u914d\u7f6e\u9879\uff0c\u65b9\u4fbf\u7ebf\u4e0a\u52a8\u6001\u8c03\u6574\u3002\u7279\u522b\u6ce8\u610f\uff1a\u5728\u521a\u542f\u52a8\u65f6\uff0c\u5982\u679c\u673a\u5668\u6216\u4e0b\u6e38\u4f9d\u8d56\u51fa\u73b0\u6545\u969c\uff0c\u6b64\u5904\u7684\u989d\u5916\u8c03\u7528\u4f1a\u52a0\u5267\u7cfb\u7edf\u6216\u4e0b\u6e38\u7684\u8d1f\u62c5\uff0c\u56e0\u6b64\u8c03\u7528\u6b21\u6570\u9700\u8981\u5408\u7406\u914d\u7f6e\u3002<\/p>\n<p>\u6b64\u65b9\u5f0f\u53ef\u4ee5\u8ba9C2 \u7f16\u8bd1\u5668\u63d0\u524d\u5bf9\u70ed\u70b9\u4ee3\u7801\u8fdb\u884c\u4f18\u5316\uff0c\u5728\u7cfb\u7edf\u5728\u7cfb\u7edf\u7a33\u5b9a\u540e\u518d\u5c06\u6d41\u91cf\u63a5\u5165\u751f\u4ea7\u73af\u5883\uff0c\u4ece\u800c\u907f\u514d\u5bf9\u7528\u6237\u9020\u6210\u4efb\u4f55\u5f71\u54cd\u3002<\/p>\n<p>\u89c2\u5bdf\u542f\u52a8\u540e\u7684\u5404\u9879\u6307\u6807\uff0c14:56:25 \u6062\u590dHTTP\u6d41\u91cf\u6210\u529f\uff0c\u5b9e\u9a8c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p>\u6574\u4f53\u8868\u73b0\u4e0e\u4e4b\u524d\u7684\u65b9\u6848\u4e00\u76f8\u4f3c\uff0c\u4f46\u662f\u6709\u4e00\u4e2a\u663e\u8457\u7684\u533a\u522b\uff1a\u5728\u6062\u590d HTTP \u6d41\u91cf\u4e4b\u524d\uff0cRunnable \u7ebf\u7a0b\u6570\u51fa\u73b0\u4e86\u660e\u663e\u7684\u7a81\u523a\uff0c\u800c\u5728\u6d41\u91cf\u6062\u590d\u540e\uff0c\u8fd9\u79cd\u7a81\u523a\u73b0\u8c61\u5219\u4e0d\u518d\u51fa\u73b0\uff0c\u7ebf\u7a0b\u6570\u5df2\u7ecf\u8d8b\u4e8e\u5e73\u7a33\u3002\u6211\u4eec\u6ce8\u610f\u5230\u7a81\u523a\u51fa\u73b0\u7684\u65f6\u95f4\u8282\u70b9\u662f14:55:25\uff0c\u8fd9\u4e2a\u65f6\u95f4\u70b9\u6b63\u597d\u662f\u6211\u4eec\u9884\u70ed\u65f6\u53d1\u8d77HTTP\u63a5\u53e3\u8c03\u7528\u7684\u65f6\u95f4\u3002<\/p>\n<p>\u8fd9\u8868\u660e\u901a\u8fc7\u9884\u70ed\u7b56\u7565\uff0c\u6211\u4eec\u6709\u6548\u5730\u524d\u7f6e\u4e86\u7cfb\u7edf\u7684\u8d1f\u8f7d\u6ce2\u52a8\u3002\u5f53\u771f\u6b63\u7684\u7528\u6237\u8bf7\u6c42\u5230\u8fbe\u65f6\uff0c\u7cfb\u7edf\u5df2\u7ecf\u8d8b\u4e8e\u5e73\u7a33\uff0c\u670d\u52a1\u54cd\u5e94\u901f\u5ea6\u4fdd\u6301\u7a33\u5b9a\uff0c\u4ece\u800c\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u66f4\u52a0\u6d41\u7545\u7684\u4f53\u9a8c\u3002<\/p>\n<p><strong>\u2460 CPU\u4f7f\u7528\u7387\u60c5\u51b5\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060425\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>CPU\u4f7f\u7528\u7387<\/p>\n<p><strong>\u2461 \u7ebf\u7a0b\u6307\u6807\u5982\u4e0b\uff1a<\/strong><\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060426\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Runnable\u7ebf\u7a0b\u6570<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000047060427\" alt=\"\u56fe\u7247\" title=\"\u56fe\u7247\" loading=\"lazy\"><\/p>\n<p>Blocked\u7ebf\u7a0b\u6570<\/p>\n<h2>\u516d\u3001\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u9488\u5bf9\u670d\u52a1\u542f\u52a8\u540e\u51e0\u5206\u949f\u5185 CPU \u6301\u7eed\u5904\u4e8e\u9ad8\u5cf0\u72b6\u6001\u7684\u95ee\u9898\uff0c\u63d0\u51fa\u4e86\u81ea\u5df1\u7684\u5206\u6790\u601d\u8def\u4e0e\u89e3\u51b3\u65b9\u6848\u3002\u6700\u7ec8\u7ebf\u4e0a\u6548\u679c\u6bd4\u8f83\u663e\u8457\uff0c\u6210\u529f\u89e3\u51b3\u4e86\u6bcf\u6b21\u53d1\u7248\u8fc7\u7a0b\u4e2d\u9891\u7e41\u544a\u8b66\u3001\u4e1a\u52a1\u53d7\u635f\u4ee5\u53ca\u7528\u6237\u4f53\u9a8c\u4e0d\u4f73\u7684\u95ee\u9898\uff0c\u4e3a\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u589e\u6dfb\u4e86\u4e00\u9053\u91cd\u8981\u4fdd\u969c\u3002\u6700\u521d\u7684\u5206\u6790\u4e0d\u591f\u6df1\u5165\uff0c\u5bfc\u81f4\u5728\u5185\u5b58\u7f13\u5b58\u9884\u70ed\u65b9\u9762\u7684\u52aa\u529b\u672a\u80fd\u4ea7\u751f\u9884\u671f\u6548\u679c\u3002\u56e0\u6b64\u5728\u672a\u6765\u9047\u5230\u7c7b\u4f3c\u95ee\u9898\u65f6\uff0c\u6211\u4eec\u5fc5\u987b\u6df1\u5165\u6316\u6398\uff0c\u76f4\u81f3\u627e\u5230\u95ee\u9898\u7684\u6839\u672c\u539f\u56e0\u3002<\/p>\n<p>\u672c\u6587\u7684\u91cd\u70b9\u5728\u4e8e\u95ee\u9898\u7684\u53d1\u73b0\u3001\u5206\u6790\u53ca\u89e3\u51b3\u601d\u8def\u3002\u5bf9\u4e8e CPU \u76f8\u5173\u7684\u95ee\u9898\uff0c\u706b\u7130\u56fe\u548c Arthas \u662f\u975e\u5e38\u6709\u6548\u7684\u5de5\u5177\uff0c\u5efa\u8bae\u5927\u5bb6\u5728\u9047\u5230\u7c7b\u4f3c\u60c5\u51b5\u65f6\uff0c\u79ef\u6781\u5c1d\u8bd5\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\u8fdb\u884c\u6392\u67e5\u548c\u89e3\u51b3\u3002<\/p>\n<p>\u6b64\u5916HTTP \u8bf7\u6c42\u672a\u5b9a\u4e49\u5c5e\u6027\u7684\u95ee\u9898\u666e\u904d\u5b58\u5728\uff0c\u7279\u522b\u662f\u5728\u670d\u52a1\u672a\u8fdb\u884c\u9884\u70ed\u542f\u52a8\u65f6\uff0c\u4f1a\u52a0\u5267 CPU \u7684\u8d1f\u8f7d\u3002\u5bf9\u4e8e\u5927\u6d41\u91cf\u670d\u52a1\u800c\u8a00\uff0c\u9047\u5230\u6b64\u7c7b\u95ee\u9898\u65f6\uff0c\u9700\u89c4\u8303\u8bf7\u6c42\u53c2\u6570\uff0c\u4ee5\u51cf\u8f7bCPU\u8d1f\u62c5\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047060399\">https:\/\/segmentfault.com\/a\/1190000047060399<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1avivo \u4e92\u8054\u7f51\u670d\u52a1\u5668\u56e2\u961f- Xie Xiaopeng \u672c\u6587\u9488\u5bf9\u670d\u52a1\u542f\u52a8\u540e\u51e0\u5206\u949f\u5185 CPU \u6301\u7eed\u5904\u4e8e\u9ad8\u5cf0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020918","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020918"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020918\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}