{"id":10020959,"date":"2025-08-19T21:29:32","date_gmt":"2025-08-19T13:29:32","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020959"},"modified":"2025-08-19T21:29:32","modified_gmt":"2025-08-19T13:29:32","slug":"rust-%e6%80%a7%e8%83%bd%e6%8f%90%e5%8d%87%e6%9c%80%e5%90%8e%e4%b8%80%e5%85%ac%e9%87%8c%ef%bc%9a%e8%af%a6%e8%a7%a3-profiling-%e7%93%b6%e9%a2%88%e5%ae%9a%e4%bd%8d%e4%b8%8e%e4%bc%98","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020959","title":{"rendered":"Rust \u6027\u80fd\u63d0\u5347\u201c\u6700\u540e\u4e00\u516c\u91cc\u201d\uff1a\u8be6\u89e3 Profiling \u74f6\u9888\u5b9a\u4f4d\u4e0e\u4f18\u5316\uff5c\u5f97\u7269\u6280\u672f"},"content":{"rendered":"<h2>\u4e00\u3001Profiling\uff1a\u63ed\u793a\u6027\u80fd\u74f6\u9888\u7684\u201c\u7167\u5996\u955c\u201d<\/h2>\n<p>\u5728\u8fc7\u53bb\u7684\u4e00\u5e74\u91cc\uff0c\u6211\u4eec\u56e2\u961f\u5b8c\u6210\u4e86\u4e00\u9879\u58ee\u4e3e\uff1a\u5c06\u8fd1\u4e07\u6838\u7684 Java \u670d\u52a1\u6210\u529f\u8fc1\u79fb\u5230 Rust\uff0c\u5e76\u6536\u83b7\u4e86\u4ee4\u4eba\u77a9\u76ee\u7684\u6027\u80fd\u63d0\u5347\u3002\u6211\u4eec\u7684\u5b9e\u8df5\u7ecf\u9a8c\u5df2\u5728\u300aRUST\u7ec3\u4e60\u751f\u5982\u4f55\u5728\u751f\u4ea7\u73af\u5883\u6784\u5efa\u4e07\u4ebf\u6d41\u91cf\u300b\u4e00\u6587\u4e2d\u4e0e\u5927\u5bb6\u5206\u4eab\u3002\u7136\u800c\uff0c\u5728\u8fd9\u6b21\u5927\u89c4\u6a21\u8fc1\u79fb\u4e2d\uff0c\u6211\u4eec\u89c2\u5bdf\u5230\u4e00\u4e2a\u6709\u8da3\u7684\u73b0\u8c61\uff1a\u5927\u591a\u6570\u670d\u52a1\u5728\u8fc1\u79fb\u540e\u6027\u80fd\u90fd\u5f97\u5230\u4e86\u663e\u8457\u63d0\u5347\uff0c\u4f46\u6709\u90a3\u4e48\u4e00\u5c0f\u90e8\u5206\u670d\u52a1\uff0c\u6027\u80fd\u63d0\u5347\u5374\u4e0d\u5c3d\u5982\u4eba\u610f\uff0c\u4ec5\u4ec5\u5728 10% \u5de6\u53f3\u5f98\u5f8a\u3002<\/p>\n<p>\u8fd9\u8ba9\u6211\u4eec\u611f\u5230\u7591\u60d1\u3002\u660e\u660e\u5df2\u7ecf\u7528\u4e0a\u4e86\u6027\u80fd\u201c\u738b\u8005\u201dRust\uff0c\u4e3a\u4ec0\u4e48\u8fd8\u4f1a\u9047\u5230\u74f6\u9888\uff1f\u4e3a\u4e86\u89e3\u5f00\u8fd9\u4e2a\u8c1c\u56e2\uff0c\u6211\u4eec\u51b3\u5b9a\u6df1\u5165\u5256\u6790\u8fd9\u4e9b\u201c\u4f4e\u63d0\u5347\u201d\u670d\u52a1\u3002\u4eca\u5929\uff0c\u6211\u5c31\u6765\u548c\u5927\u5bb6\u5206\u4eab\uff0c\u6211\u4eec\u662f\u5982\u4f55\u5229\u7528\u00a0<strong>Profiling<\/strong>\u00a0<strong>\u5de5\u5177<\/strong>\uff0c\u627e\u5230\u5e76\u89e3\u51b3\u5199\u5165\u8fc7\u7a0b\u4e2d\u7684\u6027\u80fd\u74f6\u9888\uff0c\u6700\u7ec8\u5b9e\u73b0\u66f4\u9ad8\u6027\u80fd\u98de\u8dc3\u7684\uff01<\/p>\n<p>\u5728\u6027\u80fd\u4f18\u5316\u9886\u57df\uff0c\u76f2\u76ee\u731c\u6d4b\u662f\u6700\u5927\u7684\u7981\u5fcc\u3002\u4f60\u9700\u8981\u4e00\u628a\u950b\u5229\u7684\u201c\u624b\u672f\u5200\u201d\uff0c\u7cbe\u51c6\u5730\u627e\u5230\u95ee\u9898\u7684\u6839\u6e90\u3002\u5728 Rust \u751f\u6001\u4e2d\uff0c\u867d\u7136\u4e0d\u50cf Java \u793e\u533a\u90a3\u6837\u62e5\u6709 VisualVM \u6216 JProfiler \u8fd9\u7c7b\u529f\u80fd\u5f3a\u5927\u7684\u6210\u719f\u5de5\u5177\uff0c\u4f46\u6211\u4eec\u4f9d\u7136\u53ef\u4ee5\u642d\u5efa\u4e00\u5957\u9ad8\u6548\u7684\u6027\u80fd\u5206\u6790\u4f53\u7cfb\u3002<\/p>\n<p>\u4e3a\u4e86\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u5b9e\u73b0\u9ad8\u6548\u7684\u6027\u80fd\u76d1\u63a7\uff0c\u6211\u4eec\u5f15\u5165\u4e86 <strong>Jemalloc<\/strong>\u00a0\u5185\u5b58\u5206\u914d\u5668\u548c\u00a0<strong>pprof<\/strong>\u00a0CPU \u5206\u6790\u5668\u3002\u8fd9\u5957\u65b9\u6848\u4e0d\u4ec5\u652f\u6301\u5b9a\u65f6\u81ea\u52a8\u751f\u6210 Profile \u6587\u4ef6\uff0c\u8fd8\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u89e6\u53d1\uff0c\u6781\u5927\u5730\u63d0\u5347\u4e86\u6211\u4eec\u5b9a\u4f4d\u95ee\u9898\u7684\u80fd\u529b\u3002<\/p>\n<h2>\u4e8c\u3001\u914d\u7f6e\u9879\u76ee\uff1a\u8ba9Profiling\u201c\u6b66\u88c5\u5230\u7259\u9f7f\u201d<\/h2>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728\u00a0Cargo.toml\u00a0\u6587\u4ef6\u4e2d\u6dfb\u52a0\u5fc5\u8981\u7684\u4f9d\u8d56\uff0c\u8ba9\u6211\u4eec\u7684 Rust \u670d\u52a1\u5177\u5907 Profiling \u7684\u80fd\u529b\u3002\u4ee5\u4e0b\u662f\u6211\u4eec\u7684\u914d\u7f6e\uff0cRust \u7248\u672c\u4e3a 1.87.0\u3002<\/p>\n<pre><code>[target.'cfg(all(not(target_env = &quot;msvc&quot;), not(target_os = &quot;windows&quot;)))'.dependencies]\n# \u4f7f\u7528 tikv-jemallocator \u4f5c\u4e3a\u5185\u5b58\u5206\u914d\u5668\uff0c\u5e76\u542f\u7528\u6027\u80fd\u5206\u6790\u529f\u80fd\ntikv-jemallocator\u00a0= { version =\u00a0&quot;0.6&quot;, features = [&quot;profiling&quot;,\u00a0&quot;unprefixed_malloc_on_supported_platforms&quot;] }\n# \u7528\u4e8e\u5728\u8fd0\u884c\u65f6\u63a7\u5236\u548c\u83b7\u53d6 jemalloc \u7684\u7edf\u8ba1\u4fe1\u606f\ntikv-jemalloc-ctl\u00a0= { version =\u00a0&quot;0.6&quot;, features = [&quot;use_std&quot;,\u00a0&quot;stats&quot;] }\n# tikv-jemallocator \u7684\u5e95\u5c42\u7ed1\u5b9a\uff0c\u540c\u6837\u542f\u7528\u6027\u80fd\u5206\u6790\ntikv-jemalloc-sys\u00a0= { version =\u00a0&quot;0.6&quot;, features = [&quot;profiling&quot;] }\n# \u7528\u4e8e\u751f\u6210\u4e0e pprof \u517c\u5bb9\u7684\u5185\u5b58\u5256\u6790\u6570\u636e\uff0c\u5e76\u652f\u6301\u7b26\u53f7\u5316\u548c\u706b\u7130\u56fe\njemalloc_pprof\u00a0= { version =\u00a0&quot;0.7&quot;, features = [&quot;symbolize&quot;,&quot;flamegraph&quot;] }\n# \u7528\u4e8e\u751f\u6210 CPU \u6027\u80fd\u5256\u6790\u6570\u636e\u548c\u706b\u7130\u56fe\npprof\u00a0= { version =\u00a0&quot;0.14&quot;, features = [&quot;flamegraph&quot;,\u00a0&quot;protobuf-codec&quot;] }\n<\/code><\/pre>\n<p>\u7b80\u5355\u6765\u8bf4\uff0c\u8fd9\u51e0\u4e2a\u4f9d\u8d56\u5404\u53f8\u5176\u804c\uff1a<\/p>\n<p><strong>\u203b\u00a0tikv-jemallocator<\/strong><\/p>\n<p>\u57fa\u4e8e\u00a0jemalloc\u00a0\u7684 Rust \u5b9e\u73b0\uff0c\u4ee5\u5176\u9ad8\u6548\u7684\u5185\u5b58\u7ba1\u7406\u95fb\u540d\u3002<\/p>\n<p><strong>\u203b\u00a0jemalloc\/_pprof<\/strong><\/p>\n<p>\u8d1f\u8d23\u5c06\u00a0jemalloc\u00a0\u7684\u5185\u5b58\u5256\u6790\u6570\u636e\u8f6c\u6362\u6210\u6807\u51c6\u7684 pprof \u683c\u5f0f\u3002<\/p>\n<p><strong>\u203b\u00a0pprof<\/strong><\/p>\n<p>\u7528\u4e8e CPU \u6027\u80fd\u5206\u6790\uff0c\u53ef\u4ee5\u751f\u6210\u00a0pprof\u00a0\u683c\u5f0f\u7684 Profile \u6587\u4ef6\u3002<\/p>\n<h2>\u4e09\u3001\u00a0 \u5168\u5c40\u914d\u7f6e\uff1a\u542f\u52a8Profiling\u5f00\u5173<\/h2>\n<p>\u63a5\u4e0b\u6765\uff0c\u5728\u00a0main.rs\u00a0\u4e2d\u8fdb\u884c\u5168\u5c40\u914d\u7f6e\uff0c\u6307\u5b9a <strong>Jemalloc<\/strong>\u00a0\u7684 <strong>Profiling<\/strong> \u53c2\u6570\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u7684\u5168\u5c40\u5185\u5b58\u5206\u914d\u5668\u3002<\/p>\n<pre><code>\/\/ \u914d\u7f6e Jemalloc \u5185\u5b58\u5206\u6790\u53c2\u6570\n#[export_name =\u00a0&quot;malloc_conf&quot;]\npub static malloc_conf: &amp;[u8] = b&quot;prof:true,prof_active:true,lg_prof_sample:16\/0&quot;;\n\n\n#[cfg(not(target_env =\u00a0&quot;msvc&quot;))]\nuse tikv_jemallocator::Jemalloc;\n\n\n\/\/ \u5c06 Jemalloc \u8bbe\u7f6e\u4e3a\u5168\u5c40\u5185\u5b58\u5206\u914d\u5668\n#[cfg(not(target_env =\u00a0&quot;msvc&quot;))]\n#[global_allocator]\nstatic GLOBAL: Jemalloc = Jemalloc;\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u914d\u7f6e\u4e2d\u7684\u00a0lg\/_prof\/_sample:16\u00a0\u662f\u4e00\u4e2a\u5173\u952e\u53c2\u6570\u3002<\/p>\n<p>\u5b83\u8868\u793a\u00a0jemalloc\u00a0\u4f1a\u5bf9\u5927\u7ea6\u6bcf\u00a02^16\u00a0\u5b57\u8282\uff08\u5373 64KB\uff09\u7684\u5185\u5b58\u5206\u914d\u8fdb\u884c\u4e00\u6b21\u91c7\u6837\u3002\u8fd9\u4e2a\u503c\u8d8a\u5927\uff0c\u91c7\u6837\u9891\u7387\u8d8a\u4f4e\uff0c\u5185\u5b58\u5f00\u9500\u8d8a\u5c0f\uff0c\u4f46\u7cbe\u5ea6\u4e5f\u8d8a\u4f4e\uff1b\u53cd\u4e4b\u5219\u7cbe\u5ea6\u8d8a\u9ad8\uff0c\u5f00\u9500\u8d8a\u5927\u3002\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u6743\u8861\u3002<\/p>\n<h2>\u56db\u3001\u5b9e\u73b0Profile\u751f\u6210\u51fd\u6570\uff1a\u6253\u9020\u4f60\u7684\u201c\u6570\u636e\u91c7\u96c6\u5668\u201d<\/h2>\n<p>\u6211\u4eec\u5c06 Profile \u6587\u4ef6\u7684\u751f\u6210\u903b\u8f91\u5c01\u88c5\u6210\u5f02\u6b65\u51fd\u6570\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u670d\u52a1\u7684\u4efb\u610f\u65f6\u523b\u6309\u9700\u8c03\u7528\uff0c\u975e\u5e38\u7075\u6d3b\u3002<\/p>\n<p><strong>\u5185\u5b58Profile\u751f\u6210\u51fd\u6570<\/strong><\/p>\n<pre><code>#[cfg(not(target_env =\u00a0&quot;msvc&quot;))]\nasync\u00a0fn\u00a0dump_memory_profile() -&gt;\u00a0Result&lt;String,\u00a0String&gt; {\n\u00a0 \u00a0\u00a0\/\/ \u83b7\u53d6 jemalloc \u7684 profiling \u63a7\u5236\u5668\n\u00a0 \u00a0\u00a0let\u00a0prof_ctl =\u00a0jemalloc_pprof::PROF_CTL.as_ref()\n\u00a0 \u00a0 \u00a0 \u00a0 .ok_or_else(||\u00a0&quot;Profiling controller not available&quot;.to_string())?;\n\n\n\u00a0 \u00a0\u00a0let\u00a0mut prof_ctl = prof_ctl.lock().await;\n\u00a0 \u00a0\u00a0\n\u00a0 \u00a0\u00a0\/\/ \u68c0\u67e5 profiling \u662f\u5426\u5df2\u6fc0\u6d3b\n\u00a0 \u00a0\u00a0if\u00a0!prof_ctl.activated() {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0return\u00a0Err(&quot;Jemalloc profiling is not activated&quot;.to_string());\n\u00a0 \u00a0 }\n\u00a0 \u00a0\n\u00a0 \u00a0\u00a0\/\/ \u8c03\u7528 dump_pprof() \u65b9\u6cd5\u751f\u6210 pprof \u6570\u636e\n\u00a0 \u00a0\u00a0let\u00a0pprof_data = prof_ctl.dump_pprof()\n\u00a0 \u00a0 \u00a0 \u00a0 .map_err(|e| format!(&quot;Failed to dump pprof: {}&quot;, e))?;\n\n\n\u00a0 \u00a0\u00a0\/\/ \u4f7f\u7528\u65f6\u95f4\u6233\u751f\u6210\u552f\u4e00\u6587\u4ef6\u540d\n\u00a0 \u00a0\u00a0let\u00a0timestamp =\u00a0chrono::Utc::now().format(&quot;%Y%m%d_%H%M%S&quot;);\n\u00a0 \u00a0\u00a0let\u00a0filename = format!(&quot;memory_profile_{}.pb&quot;, timestamp);\n\n\n\u00a0 \u00a0\u00a0\/\/ \u5c06 pprof \u6570\u636e\u5199\u5165\u672c\u5730\u6587\u4ef6\n\u00a0 \u00a0\u00a0std::fs::write(&amp;filename, pprof_data)\n\u00a0 \u00a0 \u00a0 \u00a0 .map_err(|e| format!(&quot;Failed to write profile file: {}&quot;, e))?;\n\n\n\u00a0 \u00a0 info!(&quot;Memory profile dumped to: {}&quot;, filename);\n\u00a0 \u00a0\u00a0Ok(filename)\n}\n<\/code><\/pre>\n<p><strong>CPU Profile\u751f\u6210\u51fd\u6570<\/strong><\/p>\n<p>\u7c7b\u4f3c\u5730\uff0c\u6211\u4eec\u4f7f\u7528\u00a0pprof\u00a0\u5e93\u6765\u5b9e\u73b0 CPU\u00a0<strong>Profile<\/strong>\u00a0\u7684\u751f\u6210\u3002<\/p>\n<pre><code>#[cfg(not(target_env = &quot;msvc&quot;))]\nasync fn dump_cpu_profile() -&gt; Result&lt;String, String&gt; {\n\u00a0 \u00a0\u00a0use\u00a0pprof::ProfilerGuard;\n\u00a0 \u00a0\u00a0use\u00a0pprof::protos::Message;\n\n\n\u00a0 \u00a0 info!(&quot;Starting CPU profiling for 60 seconds...&quot;);\n\n\n\u00a0 \u00a0\u00a0\/\/\u00a0\u521b\u5efa CPU profiler\uff0c\u8bbe\u7f6e\u91c7\u6837\u9891\u7387\u4e3a\u00a0100\u00a0Hz\n\u00a0 \u00a0 let guard = ProfilerGuard::new(100).map_err(|e|\u00a0format!(&quot;Failed to create profiler: {}&quot;, e))?;\n\n\n\u00a0 \u00a0\u00a0\/\/\u00a0\u6301\u7eed\u91c7\u6837\u00a060\u00a0\u79d2\n\u00a0 \u00a0 tokio::time::sleep(std::time::Duration::from_secs(60)).await;\n\n\n\u00a0 \u00a0\u00a0\/\/\u00a0\u751f\u6210\u62a5\u544a\n\u00a0 \u00a0 let report = guard.report().build().map_err(|e|\u00a0format!(&quot;Failed to build report: {}&quot;, e))?;\n\n\n\u00a0 \u00a0\u00a0\/\/\u00a0\u4f7f\u7528\u65f6\u95f4\u6233\u751f\u6210\u6587\u4ef6\u540d\n\u00a0 \u00a0 let timestamp = chrono::Utc::now().format(&quot;%Y%m%d_%H%M%S&quot;);\n\u00a0 \u00a0 let filename =\u00a0format!(&quot;cpu_profile_{}.pb&quot;, timestamp);\n\n\n\u00a0 \u00a0\u00a0\/\/\u00a0\u521b\u5efa\u6587\u4ef6\u5e76\u5199\u5165 pprof \u6570\u636e\n\u00a0 \u00a0 let mut file = std::fs::File::create(&amp;filename)\n\u00a0 \u00a0 \u00a0 \u00a0 .map_err(|e|\u00a0format!(&quot;Failed to create file: {}&quot;, e))?;\n\n\n\u00a0 \u00a0 report.pprof()\n\u00a0 \u00a0 \u00a0 \u00a0 .map_err(|e|\u00a0format!(&quot;Failed to convert to pprof: {}&quot;, e))?\n\u00a0 \u00a0 \u00a0 \u00a0 .write_to_writer(&amp;mut file)\n\u00a0 \u00a0 \u00a0 \u00a0 .map_err(|e|\u00a0format!(&quot;Failed to write profile: {}&quot;, e))?;\n\n\n\u00a0 \u00a0 info!(&quot;CPU profile dumped to: {}&quot;, filename);\n\u00a0 \u00a0 Ok(filename)\n}\n<\/code><\/pre>\n<ul>\n<li>\u00a0ProfilerGuard::new()\u00a0\u00a0\u00a0100\u00a0\u00a0Hz \u610f\u5473\u7740\u6bcf\u79d2\u949f\u4f1a\u968f\u673a\u4e2d\u65ad\u7a0b\u5e8f <strong>100 \u6b21<\/strong>\uff0c\u4ee5\u8bb0\u5f55\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u51fd\u6570\u8c03\u7528\u6808<\/li>\n<li>tokio::time::sleep(std::time::Duration::from\/_secs(60)).await \u8868\u793a\u00a0pprof\u00a0\u5c06\u4f1a\u6301\u7eed\u91c7\u6837 60 \u79d2\u949f<\/li>\n<li>\u00a0guard.report().build()\u00a0\u8fd9\u4e2a\u65b9\u6cd5\u7528\u4e8e\u5c06\u6536\u96c6\u5230\u7684\u6240\u6709\u91c7\u6837\u6570\u636e\u8fdb\u884c\u5904\u7406\u548c\u805a\u5408\uff0c\u6700\u7ec8\u751f\u6210\u4e00\u4e2a\u00a0Report\u00a0\u5bf9\u8c61\u3002\u8fd9\u4e2a\u00a0Report\u00a0\u5bf9\u8c61\u5305\u542b\u4e86\u6240\u6709\u8c03\u7528\u6808\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f46\u8fd8\u6ca1\u6709\u8f6c\u6362\u6210\u7279\u5b9a\u7684\u6587\u4ef6\u683c\u5f0f<\/li>\n<li>\u00a0report.pprof()\u00a0\u8fd9\u662f\u00a0Report\u00a0\u5bf9\u8c61\u7684\u4e00\u4e2a\u65b9\u6cd5\uff0c\u7528\u4e8e\u5c06\u62a5\u544a\u6570\u636e\u8f6c\u6362\u6210\u00a0pprof\u00a0\u683c\u5f0f<\/li>\n<\/ul>\n<h2>\u4e94\u3001\u00a0\u89e6\u53d1\u548c\u4f7f\u7528 Profiling\uff1a\u968f\u65f6\u968f\u5730\u6355\u6349\u6027\u80fd\u6570\u636e<\/h2>\n<p>\u6709\u4e86\u4e0a\u8ff0\u51fd\u6570\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u4e24\u79cd\u7075\u6d3b\u7684\u89e6\u53d1\u65b9\u5f0f\u3002<\/p>\n<p><strong>\u203b\u00a0\u5b9a\u65f6\u81ea\u52a8\u751f\u6210<\/strong><\/p>\n<p>\u901a\u8fc7\u5f02\u6b65\u5b9a\u65f6\u4efb\u52a1\uff0c\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u81ea\u52a8\u8c03\u7528\u00a0dump\/_memory\/_profile()\u00a0\u548c \u00a0dump\/_cpu\/_profile()\u00a0\u3002<\/p>\n<pre><code>fn start_profilers() {\n\u00a0 \u00a0\u00a0\/\/\u00a0Memory\u00a0profiler\n\u00a0 \u00a0 tokio::spawn(async {\n\u00a0 \u00a0 \u00a0 \u00a0 let mut interval = tokio::time::interval(std::time::Duration::from_secs(300));\n\u00a0 \u00a0 \u00a0 \u00a0 loop {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 interval.tick().await;\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0#[cfg(not(target_env = &quot;msvc&quot;))]\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 info!(&quot;Starting memory profiler...&quot;);\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 match dump_memory_profile().await {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0Ok(profile_path) =&gt; info!(&quot;Memory profile dumped successfully: {}&quot;, profile_path),\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0Err(e) =&gt; info!(&quot;Failed to dump memory profile: {}&quot;, e),\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 });\n\u00a0 \u00a0\u00a0\/\/\u00a0\u540c\u7406\u53ef\u4ee5\u5b9e\u73b0CPU\u00a0profiler\n}\n<\/code><\/pre>\n<p><strong>\u203b\u00a0\u624b\u52a8 HTTP \u89e6\u53d1<\/strong><\/p>\n<p>\u901a\u8fc7\u63d0\u4f9b\u00a0\/profile\/memory\u00a0\u548c\u00a0\/profile\/cpu\u00a0\u4e24\u4e2a HTTP \u63a5\u53e3\uff0c\u53ef\u4ee5\u968f\u65f6\u6309\u9700\u89e6\u53d1 Profile \u6587\u4ef6\u7684\u751f\u6210\u3002<\/p>\n<pre><code>async fn trigger_memory_profile() -&gt;\u00a0Result&lt;impl warp::Reply, std::convert::Infallible&gt; {\n\u00a0 \u00a0\u00a0#[cfg(not(target_env = &quot;msvc&quot;))]\n\u00a0 \u00a0 {\n\u00a0 \u00a0 \u00a0 \u00a0 info!(&quot;HTTP triggered memory profile dump...&quot;);\n\u00a0 \u00a0 \u00a0 \u00a0 match dump_memory_profile().await {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0Ok(profile_path) =&gt;\u00a0Ok(warp::reply::with_status(\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 format!(&quot;Memory profile dumped successfully: {}&quot;, profile_path),\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 warp::http::StatusCode::OK,\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 )),\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0Err(e) =&gt;\u00a0Ok(warp::reply::with_status(\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 format!(&quot;Failed to dump memory profile: {}&quot;, e),\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 warp::http::StatusCode::INTERNAL_SERVER_ERROR,\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 )),\n\u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 }\n}\n\/\/\u540c\u7406\u4e5f\u53ef\u5b9e\u73b0trigger_cpu_profile()\u51fd\u6570\n<\/code><\/pre>\n<p>&lt;!&#8212;-&gt;<\/p>\n<pre><code>fn profile_routes() -&gt; impl\u00a0Filter&lt;Extract\u00a0= impl\u00a0Reply,\u00a0Error\u00a0= warp::Rejection&gt; +\u00a0Clone\u00a0{\n\u00a0 \u00a0 let memory_profile = warp::post()\n\u00a0 \u00a0 \u00a0 \u00a0 .and(warp::path(&quot;profile&quot;))\n\u00a0 \u00a0 \u00a0 \u00a0 .and(warp::path(&quot;memory&quot;))\n\u00a0 \u00a0 \u00a0 \u00a0 .and(warp::path::end())\n\u00a0 \u00a0 \u00a0 \u00a0 .and_then(trigger_memory_profile);\n\u00a0 \u00a0\u00a0\n\u00a0 \u00a0\u00a0\n\u00a0 \u00a0 let cpu_profile = warp::post()\n\u00a0 \u00a0 \u00a0 \u00a0 .and(warp::path(&quot;profile&quot;))\n\u00a0 \u00a0 \u00a0 \u00a0 .and(warp::path(&quot;cpu&quot;))\n\u00a0 \u00a0 \u00a0 \u00a0 .and(warp::path::end())\n\u00a0 \u00a0 \u00a0 \u00a0 .and_then(trigger_cpu_profile);\n\u00a0 \u00a0 memory_profile.or(cpu_profile)\n}\n<\/code><\/pre>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u00a0curl\u00a0\u547d\u4ee4\uff0c\u968f\u65f6\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u91c7\u96c6\u6027\u80fd\u6570\u636e\u4e86\uff1a<\/p>\n<pre><code>curl -X POST http:\/\/localhost:8080\/profile\/memory\ncurl -X POST http:\/\/localhost:8080\/profile\/cpu\n<\/code><\/pre>\n<p>\u751f\u6210\u7684\u00a0.pb\u00a0\u6587\u4ef6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u00a0go tool pprof\u00a0\u5de5\u5177\uff0c\u542f\u52a8\u4e00\u4e2a\u4ea4\u4e92\u5f0f Web UI\uff0c\u5728\u6d4f\u89c8\u5668\u4e2d\u76f4\u89c2\u67e5\u770b\u8c03\u7528\u56fe\u3001\u706b\u7130\u56fe\u7b49\u3002<\/p>\n<pre><code>go tool pprof -http=localhost:8080 .\/target\/debug\/otel-storage .\/otel_storage_cpu_profile_20250806_032509.pb\n<\/code><\/pre>\n<h2>\u516d\u3001\u6027\u80fd\u5256\u6790\uff1a\u706b\u7130\u56fe\u4e0b\u7684\u201c\u771f\u76f8\u201d<\/h2>\n<p>\u901a\u8fc7\u00a0go tool pprof\u00a0\u542f\u52a8\u7684 Web UI\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7a0b\u5e8f\u7684<strong>\u706b\u7130\u56fe<\/strong>\u3002<\/p>\n<p><strong>\u5982\u4f55\u9605\u8bfb\u706b\u7130\u56fe<\/strong><\/p>\n<p><strong>\u203b \u9876\u90e8\uff1a<\/strong> \u4ee3\u8868\u7a0b\u5e8f\u7684\u6839\u51fd\u6570\u3002<\/p>\n<p><strong>\u203b \u5411\u4e0b\u5ef6\u4f38\uff1b<\/strong> \u5b50\u51fd\u6570\u8c03\u7528\u5173\u7cfb\u3002<\/p>\n<p><strong>\u203b \u706b\u7130\u6761\u7684\u5bbd\u5ea6\uff1a<\/strong> \u4ee3\u8868\u8be5\u51fd\u6570\u5728 CPU \u4e0a\u6d88\u8017\u7684\u65f6\u95f4\u3002<strong>\u5bbd\u5ea6\u8d8a\u5bbd\uff0c\u6d88\u8017\u7684\u65f6\u95f4\u8d8a\u591a\uff0c\u8d8a\u53ef\u80fd\u5b58\u5728\u6027\u80fd\u74f6\u9888<\/strong>\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"359\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdl606\" alt=\"image.png\" title=\"image.png\"><\/p>\n<p>CPU Profile<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"349\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdl607\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>Memory Profile<\/p>\n<p>\u5728\u6211\u4eec\u7684 CPU \u706b\u7130\u56fe\u4e2d\uff0c\u4e00\u4e2a\u4ee4\u4eba\u610f\u5916\u7684\u74f6\u9888\u6d6e\u51fa\u6c34\u9762\uff1a<strong>OSS::new<\/strong>\u00a0\u5360\u7528\u4e86\u7ea6 19.1% \u7684 CPU \u65f6\u95f4\u3002\u6df1\u5165\u5206\u6790\u540e\u53d1\u73b0\uff0c\u00a0OSS::new\u00a0\u5185\u90e8\u7684\u00a0TlsConnector\u00a0\u5728\u6bcf\u6b21\u65b0\u5efa\u8fde\u63a5\u65f6\u90fd\u4f1a\u8fdb\u884c TLS \u63e1\u624b\uff0c\u8fd9\u662f\u5bfc\u81f4 CPU \u5360\u7528\u8fc7\u9ad8\u7684\u6839\u672c\u539f\u56e0\u3002<\/p>\n<p>\u539f\u6765\uff0c\u6211\u4eec\u7684\u4ee3\u7801\u5728\u6bcf\u6b21\u5199\u5165 OSS \u65f6\uff0c\u90fd\u4f1a\u65b0\u5efa\u4e00\u4e2a OSS \u5b9e\u4f8b\uff0c\u968f\u4e4b\u800c\u6765\u7684\u662f\u4e00\u4e2a\u5168\u65b0\u7684 HTTP \u5ba2\u6237\u7aef\u548c\u4e00\u6b21\u8017\u65f6\u7684 TLS \u63e1\u624b\u3002\u5c3d\u7ba1\u00a0oss-rust-sdk\u00a0\u5185\u90e8\u6709\u8fde\u63a5\u6c60\u673a\u5236\uff0c\u4f46\u7531\u4e8e\u6211\u4eec\u6bcf\u6b21\u90fd\u521b\u5efa\u4e86\u65b0\u5b9e\u4f8b\uff0c\u8fd9\u4e2a\u8fde\u63a5\u6c60\u6839\u672c\u65e0\u6cd5\u53d1\u6325\u4f5c\u7528\uff01<\/p>\n<h2>\u4e03\u3001\u4f18\u5316\u65b9\u6848\uff1a\u4ece\u201c\u6bcf\u6b21\u65b0\u5efa\u201d\u5230\u201c\u5171\u4eab\u590d\u7528\u201d<\/h2>\n<p>\u95ee\u9898\u7684\u6838\u5fc3\u5728\u4e8e\u91cd\u590d\u521b\u5efa OSS \u5b9e\u4f8b\u3002\u6211\u4eec\u7684\u4f18\u5316\u601d\u8def\u975e\u5e38\u6e05\u6670\uff1a<strong>\u590d\u7528 OSS \u5ba2\u6237\u7aef\u5b9e\u4f8b\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684 TLS \u63e1\u624b\u5f00\u9500<\/strong>\u3002<\/p>\n<p><strong>\u4f18\u5316\u524d<\/strong><\/p>\n<p>\u6bcf\u6b21\u5199\u5165\u90fd\u65b0\u5efa OSS \u5ba2\u6237\u7aef\u3002<\/p>\n<pre><code>fn\u00a0write_oss() {\n\u00a0 \u00a0\u00a0\/\/ \u6bcf\u6b21\u5199\u5165\u90fd\u65b0\u5efa\u4e00\u4e2aOSS\u5b9e\u4f8b\n\u00a0 \u00a0\u00a0let\u00a0oss_instance =\u00a0create_oss_client(oss_config.clone());\n\u00a0 \u00a0\u00a0tokio::spawn(async\u00a0move {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u83b7\u53d6\u5199\u5165\u504f\u79fb\u91cf\u3001\u6587\u4ef6\u540d\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u6784\u9020OSS\u5199\u5165\u6240\u9700\u8d44\u6e90\u548c\u5934\u4fe1\u606f\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0\/\/ \u5199\u5165OSS\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0let\u00a0result = oss_instance\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .append_object(data, file_name, headers, resources)\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 .await;\n}\nfn\u00a0create_oss_client(config:\u00a0OssWriteConfig) -&gt;\u00a0OSS\u00a0{\n\u00a0 \u00a0\u00a0OSS::new(\n\u00a0 \u00a0 \u2026\u2026\n\u00a0 \u00a0 )\n}\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6848\u5728\u6d41\u91cf\u8f83\u5c0f\u65f6\u53ef\u80fd\u95ee\u9898\u4e0d\u5927\uff0c\u4f46\u5728\u4e07\u4ebf\u6d41\u91cf\u7684\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u9891\u7e41\u7684\u5b9e\u4f8b\u521b\u5efa\u4f1a\u9020\u6210\u5de8\u5927\u7684\u6027\u80fd\u6d6a\u8d39\u3002<\/p>\n<p><strong>\u4f18\u5316\u524d<\/strong><\/p>\n<p><strong>\u203b \u5171\u4eab\u5b9e\u4f8b<\/strong><\/p>\n<p>\u8ba9\u6bcf\u4e2a\u5904\u7406\u4efb\u52a1\uff08\u00a0DecodeTask\u00a0\uff09\u6301\u6709\u00a0Arc&lt;OSS&gt;\u00a0\u5171\u4eab\u667a\u80fd\u6307\u9488\uff0c\u786e\u4fdd\u6240\u6709\u5199\u5165\u64cd\u4f5c\u90fd\u4f7f\u7528\u540c\u4e00\u4e2a OSS \u5b9e\u4f8b\u3002<\/p>\n<pre><code>let oss_client =\u00a0Arc::new(create_oss_client(oss_config.clone()));\nlet oss_instance =\u00a0self.oss_client.clone();\u00a0\n\/\/ ...\nlet result = oss_instance\n\u00a0 \u00a0 .append_object(data, file_name, headers, resources)\n\u00a0 \u00a0 .await;\n<\/code><\/pre>\n<p><strong>\u203b \u81ea\u52a8\u91cd\u5efa\u673a\u5236<\/strong><\/p>\n<p>\u4e3a\u4e86\u5e94\u5bf9\u8fde\u63a5\u5931\u6548\u6216\u7f51\u7edc\u95ee\u9898\uff0c\u6211\u4eec\u5f15\u5165\u4e86\u81ea\u52a8\u91cd\u5efa\u673a\u5236\u3002\u5f53\u5199\u5165\u6b21\u6570\u8fbe\u5230\u9608\u503c\u6216\u53d1\u751f\u5199\u5165\u5931\u8d25\u65f6\uff0c\u6211\u4eec\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 OSS \u5b9e\u4f8b\u6765\u66ff\u6362\u65e7\u5b9e\u4f8b\uff0c\u4ece\u800c\u4fdd\u8bc1\u670d\u52a1\u7684\u5065\u58ee\u6027\u3002<\/p>\n<pre><code>\/\/ \u4f7f\u7528\u539f\u5b50\u64cd\u4f5c\u786e\u4fdd\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u7684\u8ba1\u6570\u5b89\u5168\nlet write_count =\u00a0self.oss_write_count.load(std::sync::atomic::Ordering::SeqCst);\nlet failure_count =\u00a0self.oss_failure_count.load(std::sync::atomic::Ordering::SeqCst);\n\n\n\/\/ \u68c0\u67e5\u662f\u5426\u9700\u8981\u91cd\u5efa\u5b9e\u4f8b...\nfn\u00a0recreate_oss_client(&amp;mut\u00a0self)\u00a0{\n\u00a0\n\u00a0 \u00a0 let new_oss_client =\u00a0Arc::new(create_oss_client(self.oss_config.clone()));\n\u00a0 \u00a0\u00a0self.oss_client = new_oss_client;\n\u00a0 \u00a0\u00a0self.oss_write_count.store(0, std::sync::atomic::Ordering::SeqCst);\n\u00a0 \u00a0\u00a0self.oss_failure_count.store(0, std::sync::atomic::Ordering::SeqCst);\n\u00a0 \u00a0\u00a0\/\/ \u8bb0\u5f55OSS\u5ba2\u6237\u7aef\u91cd\u5efa\u6b21\u6570\u6307\u6807\n\u00a0 \u00a0 OSS_CLIENT_RECREATE_COUNT\n\u00a0 \u00a0 \u00a0 \u00a0 .with_label_values(&amp;[])\n\u00a0 \u00a0 \u00a0 \u00a0 .inc();\n\u00a0 \u00a0 info!(&quot;OSS client recreated&quot;);\n}\n<\/code><\/pre>\n<h2>\u516b\u3001\u4f18\u5316\u6548\u679c\uff1a\u6027\u80fd\u6570\u636e\u201c\u4e00\u98de\u51b2\u5929\u201d<\/h2>\n<p>\u4f18\u5316\u540e\u7684\u670d\u52a1\u4e0a\u7ebf\u540e\uff0c\u6211\u4eec\u89c2\u5bdf\u5230\u4e86\u663e\u8457\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n<p><strong>CPU \u8d44\u6e90\u4f7f\u7528\u7387<\/strong><\/p>\n<p>\u540c\u6bd4\u4e0b\u964d\u7ea6 <strong>20%<\/strong> \u3002<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"320\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdl608\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>OSS \u5199\u5165\u8017\u65f6<\/strong><\/p>\n<p>\u540c\u6bd4\u4e0b\u964d\u7ea6 <strong>17.2%<\/strong> \uff0c\u6210\u4e3a\u96c6\u7fa4\u4e2d\u6700\u77ed\u7684\u5199\u5165\u8017\u65f6\u3002<\/p>\n<p><strong>\u203b\u00a0OSS\u5199\u5165\u8017\u65f6<\/strong><\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"334\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdl61d\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>\u203b\u00a0OSS\u76f8\u5173\u8d44\u6e90\u53ea\u5360\u5343\u5206\u4e4b\u4e00<\/strong><\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"174\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdl65b\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>\u5185\u5b58\u4f7f\u7528\u7387<\/strong><\/p>\n<p>\u5e73\u5747\u4e0b\u964d <strong>8.77%<\/strong> \uff0c\u8fd9\u90e8\u5206\u4e0b\u964d\u53ef\u80fd\u4e5f\u5f97\u76ca\u4e8e\u6211\u4eec\u5c06\u5185\u5b58\u5206\u914d\u5668\u4ece <strong>mimalloc<\/strong> \u66ff\u6362\u4e3a\u00a0<strong>jemalloc<\/strong> \u7684\u7efc\u5408\u6548\u679c\u3002<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"217\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdl61o\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u6b21\u4f18\u5316\u4e0d\u4ec5\u89e3\u51b3\u4e86\u7279\u5b9a\u670d\u52a1\u7684\u6027\u80fd\u95ee\u9898\uff0c\u66f4\u91cd\u8981\u7684\u662f\uff0c\u5b83\u9a8c\u8bc1\u4e86\u5728 Rust \u4e2d\u901a\u8fc7 Profiling \u5de5\u5177\u8fdb\u884c\u6df1\u5ea6\u6027\u80fd\u5206\u6790\u7684\u53ef\u884c\u6027\u3002\u5373\u4f7f\u5728\u5df2\u7ecf\u5b9e\u73b0\u4e86\u521d\u6b65\u6027\u80fd\u63d0\u5347\u7684 Rust \u670d\u52a1\u4e2d\uff0c\u4ecd\u7136\u5b58\u5728\u5de8\u5927\u7684\u4f18\u5316\u7a7a\u95f4\u3002<\/p>\n<p>\u672a\u6765\uff0c\u6211\u4eec\u5c06\u7ee7\u7eed\u63a2\u7d22\u66f4\u9ad8\u6548\u7684 Profiling \u65b9\u6848\uff0c\u5e76\u6df1\u5165\u6316\u6398\u5176\u4ed6\u6f5c\u5728\u7684\u6027\u80fd\u74f6\u9888\uff0c\u4ee5\u5728\u4e07\u4ebf\u6d41\u91cf\u7684\u751f\u4ea7\u73af\u5883\u4e2d\u5b9e\u73b0\u6781\u81f4\u7684\u6027\u80fd\u548c\u8d44\u6e90\u5229\u7528\u7387\u3002<\/p>\n<p><em>\u5f15\u7528<\/em><\/p>\n<ul>\n<li>GitHub &#8211; tikv\/jemallocator: Rust allocator using jemalloc as a backend<\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=9Pe%2BfIoTu3vyeX0qK7rWAQ%3D%3D.02oVfWKMO%2Bdb1mqZboFEv4pKNbmemyNU%2FTZxKRkzbXLWolvgTv0tYp0QvTd21eVO\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/crates.io\/crates\/jemalloc_pprof<\/a><\/li>\n<li>GitHub &#8211; google\/pprof: pprof is a tool for visualization and analysis of profiling data<\/li>\n<li>Use Case: Heap Profiling<\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=3SnW%2F6fWQyV87auHS3R4cw%3D%3D.ldy0Jhlp%2BU%2BuW0f0556ZcH4LjLQJJ4UHXcZSwFaS17Fkd8HyDkklE7AjCLlQeU75XwEv5rdPB2MEO8Met%2F%2BUVA%3D%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/jemalloc.net\/jemalloc.3.html#heap_profile_format<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=qmYynI0Gqs7%2B0LogAP90Dw%3D%3D.kG8EK6vU%2BIFM1FF61O6hDKjqgGM02X%2FtsvnTO2mUdD%2BS2PGwtIEew4IzYZCMfHUp\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/www.brendangregg.com\/flamegraphs.html<\/a><\/li>\n<li><a href=\"https:\/\/link.segmentfault.com\/?enc=TWKDD4pXHtSw15zKe5jbRA%3D%3D.ZlfrY3%2BBdx8SlUDd%2BereGtULsyCa%2BJRSMIvi%2BNda2OIpCN%2FvRfM0UVUV9OxC1no0\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/magiroux.com\/rust-jemalloc-profiling<\/a><\/li>\n<\/ul>\n<p><strong>\u5f80\u671f\u56de\u987e<\/strong><\/p>\n<p>1.Valkey \u5355\u70b9\u6027\u80fd\u6bd4\u80a9 Redis \u96c6\u7fa4\u4e86\uff1fValkey8.0 \u65b0\u7279\u6027\u5206\u6790\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>2.Java volatile \u5173\u952e\u5b57\u5230\u5e95\u662f\u4ec0\u4e48\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>3.\u793e\u533a\u641c\u7d22\u79bb\u7ebf\u56de\u6eaf\u7cfb\u7edf\u8bbe\u8ba1\uff1a\u67b6\u6784\u3001\u6311\u6218\u4e0e\u6027\u80fd\u4f18\u5316\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>4.\u6b63\u54c1\u5e93\u62cd\u7167PWA\u5e94\u7528\u7684\u5b9e\u73b0\u4e0e\u6027\u80fd\u4f18\u5316\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>5.\u5f97\u7269\u793e\u533a\u6d3b\u52a8\uff1a\u7ec4\u4ef6\u5316\u7684\u6f14\u8fdb\u4e0e\u5b9e\u8df5<\/p>\n<p>\u6587 \/\u00a0\u70af\u5e06\u00a0\u5357\u98ce<\/p>\n<p>\u5173\u6ce8\u5f97\u7269\u6280\u672f\uff0c\u6bcf\u5468\u66f4\u65b0\u6280\u672f\u5e72\u8d27<\/p>\n<p>\u8981\u662f\u89c9\u5f97\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9\u7684\u8bdd\uff0c\u6b22\u8fce\u8bc4\u8bba\u8f6c\u53d1\u70b9\u8d5e\uff5e<\/p>\n<p>\u672a\u7ecf\u5f97\u7269\u6280\u672f\u8bb8\u53ef\u4e25\u7981\u8f6c\u8f7d\uff0c\u5426\u5219\u4f9d\u6cd5\u8ffd\u7a76\u6cd5\u5f8b\u8d23\u4efb\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047177110\">https:\/\/segmentfault.com\/a\/1190000047177110<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001Profiling\uff1a\u63ed\u793a\u6027\u80fd\u74f6\u9888\u7684\u201c\u7167\u5996\u955c\u201d \u5728\u8fc7\u53bb\u7684\u4e00\u5e74\u91cc\uff0c\u6211\u4eec\u56e2\u961f\u5b8c\u6210\u4e86\u4e00\u9879\u58ee\u4e3e\uff1a\u5c06\u8fd1\u4e07\u6838\u7684 Java [&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-10020959","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\/10020959","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=10020959"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020959\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}