{"id":152,"date":"2022-11-08T04:28:21","date_gmt":"2022-11-08T12:28:21","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/?p=152"},"modified":"2022-11-08T04:29:47","modified_gmt":"2022-11-08T12:29:47","slug":"asp-net-core-7-%e4%b8%ad%e7%9a%84%e6%80%a7%e8%83%bd%e6%94%b9%e8%bf%9b","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/asp-net-core-7-%e4%b8%ad%e7%9a%84%e6%80%a7%e8%83%bd%e6%94%b9%e8%bf%9b\/","title":{"rendered":"ASP.NET Core 7 \u4e2d\u7684\u6027\u80fd\u6539\u8fdb"},"content":{"rendered":"<p><span style=\"font-size: 10pt;\"><strong><em>\u672c\u6587\u7ffb\u8bd1\u4e8eBrennan Conroy\u7684\u8fd9\u7bc7\u82f1\u6587\u6587\u7ae0\uff1a<a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/performance-improvements-in-aspnet-core-7\/\">Performance improvements in ASP.NET Core 7<\/a><\/em><\/strong><\/span>\u3002<\/p>\n<p>\u6027\u80fd\u662f .NET \u7684\u4e00\u4e2a\u7279\u6027\u3002\u5728\u6bcf\u4e2a\u7248\u672c\u4e2d\uff0c.NET \u56e2\u961f\u548c\u793e\u533a\u8d21\u732e\u8005\u90fd\u4f1a\u82b1\u65f6\u95f4\u6539\u8fdb\u6027\u80fd\uff0c\u4e3a\u7684\u662f\u4f7f.NET \u5e94\u7528\u7a0b\u5e8f\u66f4\u5feb\u5e76\u4e14\u4f7f\u7528\u66f4\u5c11\u7684\u8d44\u6e90\u3002<\/p>\n<p>\u8fd9\u7bc7\u535a\u6587\u91cd\u70b9\u4ecb\u7ecd\u4e86 ASP.NET Core 7 \u4e2d\u7684\u4e00\u4e9b\u6027\u80fd\u6539\u8fdb\u3002\u8fd9\u662f\u53bb\u5e74\u5173\u4e8e <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/performance-improvements-in-aspnet-core-6\">ASP.NET Core 6 \u6027\u80fd\u6539\u8fdb<\/a>\u7684\u6587\u7ae0\u7684\u5ef6\u7eed\u3002\u5f53\u7136\uff0c\u5b83\u7ee7\u7eed\u53d7\u5230 .<a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/performance_improvements_in_net_7\/\">NET 7 \u4e2d\u7684\u6027\u80fd\u6539\u8fdb<\/a>\u7684\u542f\u53d1\u3002\u5176\u4e2d\u8bb8\u591a\u6539\u8fdb\u95f4\u63a5\u6216\u76f4\u63a5\u5730\u63d0\u9ad8\u4e86 ASP.NET Core \u7684\u6027\u80fd\u3002<\/p>\n<p><strong>\u57fa\u51c6\u8bbe\u7f6e<\/strong><\/p>\n<p>\u6211\u4eec\u5c06\u5728\u8fd9\u7bc7\u535a\u6587\u4e2d\u7684\u5927\u90e8\u5206\u793a\u4f8b\u4e2d\u4f7f\u7528 <a href=\"https:\/\/github.com\/dotnet\/benchmarkdotnet\">BenchmarkDotNet<\/a>\u3002<\/p>\n<p>\u9996\u5148\u8bbe\u7f6e\u57fa\u51c6\u6d4b\u8bd5\u9879\u76ee\uff1a<\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\uff08<span style=\"color: #ff0000;\">dotnet new console<\/span>\uff09<\/li>\n<li>\u6dfb\u52a0\u5bf9 BenchmarkDotnet \u7684 Nuget \u5f15\u7528\uff08<span style=\"color: #ff0000;\">dotnet add package BenchmarkDotnet<\/span>\uff09version 0.13.2+<\/li>\n<li>\u5c06Program.cs \u66f4\u6539\u4e3a <span style=\"color: #ff0000;\">var summary = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run()<\/span>;<\/li>\n<li>\u5728\u4e0b\u9762\u6dfb\u52a0\u60a8\u8981\u8fd0\u884c\u7684\u57fa\u51c6\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5<\/li>\n<li>\u8fd0\u884c <span style=\"color: #ff0000;\">dotnet run -c Release<\/span> \u5e76\u5728\u51fa\u73b0\u63d0\u793a\u65f6\u8f93\u5165\u8981\u8fd0\u884c\u7684\u57fa\u51c6\u6d4b\u8bd5\u7684\u7f16\u53f7<\/li>\n<\/ol>\n<p>\u6709\u4e9b\u57fa\u51c6\u6d4b\u8bd5\u5185\u90e8\u7c7b\u578b\uff0c\u65e0\u6cd5\u7f16\u5199\u81ea\u5305\u542b\u57fa\u51c6\u3002 \u5728\u8fd9\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u5c06\u53c2\u8003\u901a\u8fc7\u5728\u5b58\u50a8\u5e93\u4e2d\u8fd0\u884c\u57fa\u51c6\u83b7\u5f97\u7684\u6570\u5b57\uff0c\u6216\u8005\u6211\u5c06\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5316\u7684\u793a\u4f8b\u6765\u5c55\u793a\u6539\u8fdb\u7684\u4f5c\u7528\u3002<\/p>\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4f1a\u53c2\u8003\u6211\u4eec\u5728 https:\/\/aka.ms\/aspnet\/benchmarks \u4e0a\u516c\u5f00\u7684\u7aef\u5230\u7aef\u57fa\u51c6\u3002 \u4f46\u662f\u6211\u4eec\u53ea\u663e\u793a\u6700\u8fd1\u51e0\u4e2a\u6708\u7684\u6570\u636e\uff0c\u662f\u4e3a\u4e86\u65b9\u4fbf\u9875\u9762\u5728\u5408\u7406\u7684\u65f6\u95f4\u5185\u52a0\u8f7d\u3002<\/p>\n<p><strong>\u901a\u7528\u670d\u52a1\u5668<\/strong><\/p>\n<p>Ampere \u673a\u5668\u57fa\u4e8e ARM\uff0c\u5177\u6709\u8bb8\u591a\u5185\u6838\uff0c\u5e76\u4e14\u7531\u4e8e\u5176\u8f83\u4f4e\u7684\u529f\u8017\u548c\u4e0e x64 \u673a\u5668\u7684\u5947\u5076\u6027\u800c\u88ab\u7528\u4f5c\u4e91\u73af\u5883\u4e2d\u7684\u670d\u52a1\u5668\u3002 \u4f5c\u4e3a .NET 7 \u7684\u4e00\u90e8\u5206\uff0c\u6211\u4eec\u786e\u5b9a\u4e86\u8bb8\u591a\u6838\u5fc3\u673a\u5668\u65e0\u6cd5\u5f88\u597d\u5730\u6269\u5c55\u7684\u4e00\u4e9b\u9886\u57df\uff0c\u5e76\u4fee\u590d\u5b83\u4eec\u4ee5\u5e26\u6765\u5de8\u5927\u7684\u6027\u80fd\u63d0\u5347\u3002 <a href=\"https:\/\/github.com\/dotnet\/runtime\/pull\/69386\">dotnet\/runtime#69386<\/a> \u548c <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/42237\">dotnet\/aspnetcore#42237<\/a> \u5206\u522b\u5bf9\u5168\u5c40\u7ebf\u7a0b\u6c60\u961f\u5217\u548c\u5957\u63a5\u5b57\u8fde\u63a5\u4f7f\u7528\u7684\u5185\u5b58\u6c60\u8fdb\u884c\u4e86\u5206\u533a\u3002 \u5206\u533a\u4f7f\u5185\u6838\u80fd\u591f\u5728\u81ea\u5df1\u7684\u961f\u5217\u4e0a\u8fd0\u884c\uff0c\u8fd9\u6709\u52a9\u4e8e\u51cf\u5c11\u4e89\u7528\u5e76\u63d0\u9ad8\u5927\u578b\u5185\u6838\u8ba1\u7b97\u673a\u7684\u53ef\u6269\u5c55\u6027\u3002 \u5728\u6211\u4eec\u7684 80 \u6838 Ampere \u673a\u5668\u4e0a\uff0c\u660e\u6587\u5e73\u53f0\u57fa\u51c6\u63d0\u9ad8 514%\uff0c240 \u4e07 RPS \u5230 1460 \u4e07 RPS\uff0cJSON \u5e73\u53f0\u63d0\u9ad8 311%\uff0c270k RPS \u5230 110 \u4e07 RPS\uff01<\/p>\n<p>\u4e3a\u4e86\u63d0\u9ad8\u6027\u80fd\uff0c\u6211\u4eec\u505a\u4e86\u4e00\u4e9b\u6743\u8861\u3002 \u9996\u5148\uff0c\u5de5\u4f5c\u9879\u5230\u5168\u5c40\u7ebf\u7a0b\u961f\u5217\u7684\u4e25\u683c FIFO \u6392\u5e8f\u4e0d\u518d\u5f97\u5230\u4fdd\u8bc1\uff0c\u56e0\u4e3a\u73b0\u5728\u6709\u591a\u4e2a\u961f\u5217\u88ab\u8bfb\u53d6\u3002 \u5176\u6b21\uff0c\u5f53\u673a\u5668\u7531\u4e8e\u5de5\u4f5c\u7a83\u53d6\u800c\u5904\u4e8e\u4f4e\u8d1f\u8f7d\u72b6\u6001\u65f6\uff0c\u9700\u8981\u66f4\u591a\u7684\u961f\u5217\u6765\u641c\u7d22\u5de5\u4f5c\uff0cCPU \u4f7f\u7528\u7387\u53ef\u80fd\u4f1a\u7565\u6709\u589e\u52a0\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/runtime\/pull\/64834\">dotnet\/runtime#64834<\/a> \u5e26\u6765\u4e86\u4e00\u4e2a\u91cd\u5927\u53d8\u5316\uff08\u7279\u5b9a\u4e8e Windows\uff09\uff0c\u5b83\u5c06 Windows IO \u6c60\u5207\u6362\u4e3a\u4f7f\u7528\u6258\u7ba1\u5b9e\u73b0\u3002 \u867d\u7136\u8fd9\u4e00\u53d8\u5316\u672c\u8eab\u5e26\u6765\u4e86\u6027\u80fd\u6539\u8fdb\uff0c\u4f8b\u5982\u6211\u4eec\u7684 JSON \u5e73\u53f0\u57fa\u51c6\u6d4b\u8bd5\u7684 RPS \u589e\u52a0\u4e86\u7ea6 11%\uff0c\u4f46\u5b83\u8fd8\u5141\u8bb8\u6211\u4eec\u5728 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/43449\">dotnet\/aspnetcore#43449<\/a> \u4e2d\u5220\u9664\u4e4b\u524d\u5b58\u5728\u7684 Kestrel \u4e2d\u7684\u7ebf\u7a0b\u6c60\u8c03\u5ea6 IO \u7ebf\u7a0b\u3002 \u5728 Windows \u4e0a\u5220\u9664\u8c03\u5ea6\u4f7f RPS \u518d\u589e\u52a0\u7ea6 18%\uff0c\u5bfc\u81f4\u603b RPS \u589e\u52a0\u7ea6 27%\uff0c\u4ece 800k RPS \u589e\u52a0\u5230 110 \u4e07 RPS\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/runtime\/issues\/12892\">\u629b\u51fa\u5f02\u5e38\u53ef\u80fd\u4ee3\u4ef7\u9ad8\u6602<\/a>\uff0c\u5e76\u4e14 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/38094\">dotnet\/aspnetcore#38094<\/a> \u6807\u8bc6\u4e86 Kestrel \u7684 Socket \u4f20\u8f93\u4e2d\u7684\u4e00\u4e2a\u533a\u57df\uff0c\u6211\u4eec\u53ef\u4ee5\u907f\u514d\u5728\u8fde\u63a5\u5173\u95ed\u671f\u95f4\u5728\u67d0\u4e2a\u5c42\u629b\u51fa\u5f02\u5e38\u3002 \u5728\u6211\u4eec\u7684\u8fde\u63a5\u5173\u95ed\u57fa\u51c6\u6d4b\u8bd5\u4e2d\uff0c\u4e0d\u629b\u51fa\u5f02\u5e38\u4f1a\u964d\u4f4e CPU \u4f7f\u7528\u7387\u3002 Linux \u4e0a 50% \u5230 40% CPU\uff0cWindows \u4e0a 15% \u5230 14% CPU\uff0c28 \u6838 ARM Linux \u4e0a 24% \u5230 18% CPU\uff01 \u66f4\u6539\u7684\u53e6\u4e00\u4e2a\u4e0d\u9519\u7684\u526f\u4f5c\u7528\u662f\u6bcf\u79d2\u7684\u5f02\u5e38\u6570\u91cf\uff08\u5982\u4e0b\u56fe\u6240\u793a\uff09\u6025\u5267\u4e0b\u964d\uff0c\u8fd9\u603b\u662f\u4e00\u4ef6\u597d\u4e8b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/10\/net7_exceptionsgraph.png\" \/><\/p>\n<p>\u6211\u4eec\u5728 6.0 \u4e2d\u5f00\u59cb\u4f7f\u7528 PoolingAsyncValueTaskMethodBuilder \u548c <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/35011\">dotnet\/aspnetcore#35011<\/a>\uff0c\u5b83\u66f4\u65b0\u4e86 Kestrel \u4e2d\u7684\u8bb8\u591a ReadAsync \u65b9\u6cd5\uff0c\u4ee5\u51cf\u5c11\u4ece\u8bf7\u6c42\u4e2d\u8bfb\u53d6\u65f6\u4f7f\u7528\u7684\u5185\u5b58\u3002 \u5728 7.0 \u4e2d\uff0c\u6211\u4eec\u5c06 PoolingAsyncValueTaskMethodBuilder \u5e94\u7528\u4e8e <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/41345\">dotnet\/aspnetcore#41345<\/a>\u3001<a href=\"https:\/\/github.com\/dotnet\/runtime\/issues\/68467\">dotnet\/runtime#68467<\/a> \u548c <a href=\"https:\/\/github.com\/dotnet\/runtime\/pull\/68457\">dotnet\/runtime#68457<\/a> \u4e2d\u7684\u66f4\u591a\u65b9\u6cd5\u3002<\/p>\n<p>WebSockets \u662f\u5c55\u793a\u5206\u914d\u5dee\u5f02\u7684\u7edd\u4f73\u793a\u4f8b\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f\u4ece\u8bf7\u6c42\u4e2d\u591a\u6b21\u8bfb\u53d6\u7684\u957f\u671f\u8fde\u63a5\u3002 \u5728\u4e0b\u56fe\u4e2d\uff0c\u4e00\u4e2a\u57fa\u51c6\u6d4b\u8bd5\u5728\u5355\u4e2a WebSocket \u8fde\u63a5\u4e0a\u6267\u884c\u4e86 1000 \u6b21\u8bfb\u53d6\u3002<\/p>\n<p>\u5728 6.0 \u4e2d\uff0c1000 \u6b21\u8bfb\u53d6\u4f1a\u5bfc\u81f4\u5206\u914d 3000 \u4e2a\u72b6\u6001\u673a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/10\/net6_websocket1000requests.png\" \/><\/p>\n<p>\u6df1\u5165\u7814\u7a76\u5b83\u4eec\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u6bcf\u6b21\u8bfb\u53d6\u4e09\u4e2a\u72ec\u7acb\u7684\u72b6\u6001\u673a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/10\/net6_statemachines.png\" \/><\/p>\n<p>\u5728 7.0 \u4e2d\uff0c\u6240\u6709\u72b6\u6001\u673a\u5206\u914d\u90fd\u5df2\u4ece WebSocket \u8fde\u63a5\u8bfb\u53d6\u4e2d\u6d88\u9664\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/10\/net7_websocket1000requests.png\" \/><\/p>\n<p>\u8bf7\u6ce8\u610f\uff0cPoolingAsyncValueTaskMethodBuilder \u4e0d\u4ec5\u4ec5\u662f\u514d\u8d39\u7684\u6027\u80fd\uff0c\u5e76\u4e14\u53ef\u4ee5\u7528\u4e8e\u6240\u6709\u5f02\u6b65 API\u3002 \u867d\u7136\u4ece\u5206\u914d\u7684\u89d2\u5ea6\u6765\u770b\u5b83\u53ef\u80fd\u770b\u8d77\u6765\u4e0d\u9519\u5e76\u4e14\u53ef\u4ee5\u6539\u8fdb\u5fae\u57fa\u51c6\uff0c\u4f46\u5b83\u5728\u5b9e\u9645\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8868\u73b0\u53ef\u80fd\u4f1a\u66f4\u5dee\u3002 \u6c60\u5316\u5728\u627f\u8bfa\u4f7f\u7528\u4e4b\u524d\u4f1a\u88ab\u5f7b\u5e95\u6d4b\u91cf\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u6211\u4eec\u53ea\u5c06\u6b64\u529f\u80fd\u5e94\u7528\u4e8e\u7279\u5b9a API \u7684\u539f\u56e0\u3002<\/p>\n<p><strong>HTTP\/2<\/strong><\/p>\n<p>\u5728 6.0 \u4e2d\uff0c\u6211\u4eec\u5728 Kestrel \u7684 HTTP\/2 \u5904\u7406\u4e2d\u53d1\u73b0\u4e86\u4e00\u4e2a\u9501\u4e89\u7528\u8f83\u9ad8\u7684\u533a\u57df\u3002 HTTP\/2 \u5177\u6709\u5355\u4e2a\u8fde\u63a5\u4e0a\u7684\u591a\u4e2a\u6d41\u7684\u6982\u5ff5\u3002\u5f53\u4e00\u4e2a\u6d41\u5199\u5165\u8fde\u63a5\u65f6\uff0c\u5b83\u9700\u8981\u4e00\u4e2a\u53ef\u4ee5\u963b\u585e\u5176\u4ed6\u5e76\u53d1\u6d41\u7684\u9501\u3002\u6211\u4eec\u5c1d\u8bd5\u4e86\u51e0\u79cd\u4e0d\u540c\u7684\u65b9\u6cd5\u6765\u63d0\u9ad8\u5e76\u53d1\u6027\u3002\u6211\u4eec\u53d1\u73b0\u4e86\u4e00\u4e2a\u6f5c\u5728\u7684\u6539\u8fdb\uff0c\u65b9\u6cd5\u662f\u5bf9 <a href=\"https:\/\/learn.microsoft.com\/dotnet\/core\/extensions\/channels\">Channel<\/a> \u7684\u5199\u5165\u8fdb\u884c\u6392\u961f\uff0c\u5e76\u8ba9\u5355\u4e2a\u6d88\u8d39\u8005\u4efb\u52a1\u5904\u7406\u961f\u5217\u5e76\u5b8c\u6210\u6240\u6709\u5199\u5165\uff0c\u4ece\u800c\u6d88\u9664\u4e86\u5927\u90e8\u5206\u7684\u9501\u4e89\u7528\u3002PR <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/40925\">dotnet\/aspnetcore#40925<\/a> \u91cd\u5199\u4e86 HTTP\/2 \u8f93\u51fa\u5904\u7406\u4ee5\u4f7f\u7528 Channel \u65b9\u6cd5\uff0c\u7ed3\u679c\u4e0d\u8a00\u800c\u55bb\u3002\u4f7f\u7528\u6bcf\u4e2a\u8fde\u63a5 70 \u4e2a\u6d41\u548c 28 \u4e2a\u8fde\u63a5\u7684 gRPC \u57fa\u51c6\u6d4b\u8bd5\uff0c\u6211\u4eec\u770b\u5230 110k RPS \u548c\u670d\u52a1\u5668 CPU \u5927\u7ea6 14%\uff0c\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u6307\u6807\uff0c\u8981\u4e48\u6211\u4eec\u6ca1\u6709\u4ece\u5ba2\u6237\u7aef\u4ea7\u751f\u8db3\u591f\u7684\u8d1f\u8f7d\uff0c\u8981\u4e48\u6709\u4ec0\u4e48\u4e1c\u897f\u963b\u6b62\u4e86\u670d\u52a1\u5668\u505a\u66f4\u591a\u7684\u5904\u7406\u3002\u66f4\u6539\u540e\uff0cRPS \u53d8\u4e3a 4.1m\uff0c\u670d\u52a1\u5668 CPU \u73b0\u5728\u4e3a 100%\uff0c\u8868\u660e\u6211\u4eec\u6b63\u5728\u751f\u6210\u8db3\u591f\u7684\u8d1f\u8f7d\uff0c\u5e76\u4e14\u670d\u52a1\u5668\u4e0d\u518d\u88ab\u9501\u4e89\u7528\u963b\u585e\uff01\u8fd9\u4e00\u53d8\u5316\u8fd8\u5c06\u5355\u6d41\u591a\u8fde\u63a5\u57fa\u51c6\u4ece 1.2m \u63d0\u9ad8\u5230 6.8m RPS\u3002\u8fd9\u4e2a\u57fa\u51c6\u6d4b\u8bd5\u4e0d\u53d7\u9501\u4e89\u7528\u7684\u5f71\u54cd\uff0c\u5e76\u4e14\u5728\u66f4\u6539\u4e4b\u524d\u5df2\u7ecf\u5904\u4e8e 100% CPU\uff0c\u6240\u4ee5\u5f53\u5b83\u901a\u8fc7\u6539\u53d8\u6211\u4eec\u5904\u7406 HTTP\/2 \u5e27\u7684\u65b9\u5f0f\u5f97\u5230\u5982\u6b64\u5927\u7684\u6539\u8fdb\u65f6\uff0c\u771f\u662f\u4ee4\u4eba\u60ca\u559c\uff01<\/p>\n<p>\u770b\u5230\u56fe\u8868\u7684\u663e\u7740\u6539\u8fdb\u603b\u662f\u5f88\u9ad8\u5174\uff0c\u56e0\u6b64\u8fd9\u91cc\u662f\u66f4\u6539\u524d\u540e\u7684\u9501\u4e89\u7528\u60c5\u51b5\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/10\/net7_grpc70s28cLockContention.png\" \/><\/p>\n<p>\u8fd9\u662f RPS \u7684\u6539\u8fdb\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2022\/10\/net7_grpc70s28c.png\" \/><\/p>\n<p>HTTP\/2 \u4e2d\u7684\u53e6\u4e00\u4e2a\u6982\u5ff5\u79f0\u4e3a\u6d41\u63a7\u5236\u3002\u6d41\u63a7\u5236\u662f\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u90fd\u91c7\u7528\u7684\u534f\u8bae\uff0c\u7528\u4e8e\u6307\u5b9a\u5728\u7b49\u5f85\u53d1\u9001\u66f4\u591a\u6570\u636e\u4e4b\u524d\u53ef\u4ee5\u5411\u4efb\u4e00\u65b9\u53d1\u9001\u591a\u5c11\u6570\u636e\u3002\u5728\u8fde\u63a5\u5f00\u59cb\u65f6\uff0c\u7a97\u53e3\u5927\u5c0f\u88ab\u6307\u5b9a\u5e76\u7528\u4f5c\u5141\u8bb8\u901a\u8fc7\u8fde\u63a5\u53d1\u9001\u7684\u6700\u5927\u6570\u636e\u91cf\uff0c\u76f4\u5230\u63a5\u6536\u5230 WINDOW_UPDATE \u5e27\u3002\u6b64\u5e27\u6307\u5b9a\u5df2\u8bfb\u53d6\u7684\u6570\u636e\u91cf\uff0c\u5e76\u8ba9\u53d1\u9001\u8005\u77e5\u9053\u53ef\u4ee5\u901a\u8fc7\u8fde\u63a5\u53d1\u9001\u66f4\u591a\u6570\u636e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cKestrel \u4f7f\u7528 96kb \u7684\u7a97\u53e3\u5927\u5c0f\uff0c\u4e00\u65e6\u8bfb\u53d6\u4e86\u5927\u7ea6\u4e00\u534a\u7684\u7a97\u53e3\uff0c\u5c31\u4f1a\u53d1\u9001 WINDOW_UPDATE\u3002\u7a97\u53e3\u5927\u5c0f\u610f\u5473\u7740\u4e0a\u4f20\u5927\u6587\u4ef6\u7684\u5ba2\u6237\u7aef\u5c06\u5728\u6536\u5230 WINDOW_UPDATE \u5e27\u4e4b\u524d\u4e00\u6b21\u5c06 48kb \u5230 96kb \u53d1\u9001\u5230\u670d\u52a1\u5668\u3002\u4f7f\u7528\u8fd9\u4e9b\u6570\u5b57\uff0c\u6211\u4eec\u53ef\u4ee5\u7c97\u7565\u5f97\u51fa\u4e00\u4e2a 108Mb \u6587\u4ef6\u548c 10ms \u5f80\u8fd4\u5ef6\u8fdf\u9700\u8981\u591a\u957f\u65f6\u95f4\u3002 108mb \/ 48kb = 2,250 \u6bb5\u3002 2,250 \u6bb5 \/ 10 \u6beb\u79d2 = 22.5 \u79d2\u4e0a\u9650\u3002 108mb \/ 96kb = 1,125 \u6bb5\u3002\u4e0b\u9650 1,125 \u6bb5 \/ 10ms = 11.25 \u79d2\u3002\u8fd9\u4e9b\u6570\u5b57\u5e76\u4e0d\u7cbe\u786e\uff0c\u56e0\u4e3a\u5728\u53d1\u9001\u548c\u5904\u7406\u6570\u636e\u65f6\u4f1a\u6709\u4e00\u4e9b\u5f00\u9500\uff0c\u4f46\u5b83\u4eec\u8ba9\u6211\u4eec\u5927\u81f4\u4e86\u89e3\u4e86\u9700\u8981\u591a\u957f\u65f6\u95f4\u3002 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/43302\">dotnet\/aspnetcore#43302<\/a> \u5c06 Kestrel \u4f7f\u7528\u7684\u9ed8\u8ba4\u7a97\u53e3\u5927\u5c0f\u589e\u52a0\u5230 768kb\uff0c\u5e76\u663e\u793a\u4e0a\u4f20 108mb \u6587\u4ef6\u73b0\u5728\u9700\u8981 4.3 \u79d2\uff0c\u800c\u4e4b\u524d\u9700\u8981 26.9 \u79d2\u3002\u65b0\u7684\u4e0a\u9650\u548c\u4e0b\u9650\u53d8\u4e3a 2.8 \u79d2 &#8211; 1.4 \u79d2\uff0c\u540c\u6837\u4e0d\u8003\u8651\u5f00\u9500\u3002<\/p>\n<p>\u8fd9\u5c31\u63d0\u51fa\u4e86\u4e00\u4e2a\u95ee\u9898\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u8ba9\u7a97\u53e3\u5c3d\u53ef\u80fd\u5927\u4ee5\u5141\u8bb8\u66f4\u5feb\u7684\u4e0a\u4f20\u5462\uff1f \u539f\u56e0\u662f\u4e00\u6b21\u53ef\u4ee5\u53d1\u9001\u591a\u5c11\u5b57\u8282\u4ecd\u7136\u5b58\u5728\u8fde\u63a5\u7ea7\u522b\u9650\u5236\uff0c\u5e76\u4e14\u8be5\u9650\u5236\u662f\u4e3a\u4e86\u907f\u514d\u4efb\u4f55\u5355\u4e2a\u8fde\u63a5\u5728\u670d\u52a1\u5668\u4e0a\u4f7f\u7528\u8fc7\u591a\u7684\u5185\u5b58\u3002<\/p>\n<p><strong>HTTP\/3<\/strong><\/p>\n<p>ASP.NET Core 6 \u5f15\u5165\u4e86\u5bf9 HTTP\/3 \u7684\u5b9e\u9a8c\u6027\u652f\u6301\u3002 \u5728 7.0 \u4e2d\uff0cHTTP\/3 \u4e0d\u518d\u662f\u5b9e\u9a8c\u6027\u7684\uff0c\u4f46\u4ecd\u53ef\u9009\u62e9\u52a0\u5165\u3002 \u8bb8\u591a\u4f7f HTTP\/3 \u6210\u4e3a\u975e\u5b9e\u9a8c\u6027\u7684\u66f4\u6539\u90fd\u56f4\u7ed5\u7740\u53ef\u9760\u6027\u3001\u6b63\u786e\u6027\u548c\u6700\u7ec8\u786e\u5b9a API \u7684\u5f62\u5f0f\u3002 \u4f46\u8fd9\u5e76\u6ca1\u6709\u963b\u6b62\u6211\u4eec\u8fdb\u884c\u6027\u80fd\u6539\u8fdb\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u4ece <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/38826\">dotnet\/aspnetcore#38826<\/a> \u7684 900 \u500d\u6027\u80fd\u63d0\u5347\u5f00\u59cb\uff0c\u5b83\u63d0\u9ad8\u4e86 HTTP\/3 \u7528\u4e8e\u7f16\u7801\u6807\u5934\u7684 QPack \u7684\u6027\u80fd\u3002 \u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u90fd\u4f7f\u7528 QPack\uff0c\u6211\u4eec\u901a\u8fc7\u4e0e ASP.NET Core \u4e2d\u7684\u670d\u52a1\u5668\u4ee3\u7801\u548c .NET \u4e2d\u7684\u5ba2\u6237\u7aef\u4ee3\u7801 (HttpClient) \u5171\u4eab .NET QPack \u5b9e\u73b0\u6765\u5229\u7528\u8fd9\u4e00\u70b9\u3002 \u56e0\u6b64\uff0c\u5bf9 QPack \u7684\u4efb\u4f55\u6539\u8fdb\u90fd\u5c06\u6709\u76ca\u4e8e\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\uff01<\/p>\n<p>QPack \u5904\u7406\u6807\u5934\u538b\u7f29\u4ee5\u66f4\u6709\u6548\u5730\u53d1\u9001\u548c\u63a5\u6536\u6807\u5934\u3002 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/38565\">dotnet\/aspnetcore#38565<\/a> \u4e3a QPack \u5f15\u5165\u4e86\u4e00\u5806\u5e38\u89c1\u7684\u5934\u6587\u4ef6\u3002 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/38681\">dotnet\/aspnetcore#38681<\/a> \u901a\u8fc7\u538b\u7f29\u4e00\u4e9b\u6807\u5934\u503c\u8fdb\u4e00\u6b65\u6539\u8fdb\u4e86 QPack\u3002<\/p>\n<p>\u7ed9\u5b9aHeaders\uff1a<\/p>\n<pre class=\"prettyprint\">headers.ContentLength = 0;\r\nheaders.ContentType = \"application\/json\";\r\nheaders.Age = \"0\";\r\nheaders.AcceptRanges = \"bytes\";\r\nheaders.AccessControlAllowOrigin = \"*\";<\/pre>\n<p>\u6700\u521d QPack \u7684\u8f93\u51fa\u662f 109 \u4e2a\u5b57\u8282\uff1a <span style=\"color: #ff0000;\">0x00 0x00 0x37 0x05 0x63 0x6F 0x6E 0x74 0x65 0x6E 0x74 0x2D 0x74 0x79 0x70 0x65 &#8230;<\/span><\/p>\n<p>\u7ecf\u8fc7\u4e0a\u9762\u7684\u4e24\u6b21\u6539\u52a8\u540e\uff0cQPack\u8f93\u51fa\u53d8\u6210\u5982\u4e0b7\u4e2a\u5b57\u8282\uff1a<span style=\"color: #ff0000;\">0x00 0x00 0xEE 0xE0 0xE3 0xC2 0xC4<\/span><\/p>\n<p>\u67e5\u770b\u4ece <span style=\"color: #ff0000;\">0x63<\/span> \u5b57\u8282\u5230 <span style=\"color: #ff0000;\">0x65<\/span> \u7684\u5b57\u8282\uff0c\u5b83\u4eec\u4ee3\u8868\u5341\u516d\u8fdb\u5236\u7684 ASCII \u5b57\u7b26\u4e32<span style=\"color: #ff0000;\">content-type<\/span>\u3002 \u5728 .NET 7 \u4e2d\uff0c\u6211\u4eec\u5c06\u8fd9\u4e9b\u538b\u7f29\u5230\u7d22\u5f15\u4e2d\uff0c\u56e0\u6b64\u672c\u793a\u4f8b\u4e2d\u7684\u6bcf\u4e2a\u6807\u5934\u90fd\u53d8\u6210\u4e86\u4e00\u4e2a\u5b57\u8282\u3002<\/p>\n<p>\u5728\u66f4\u6539\u524d\u540e\u8fd0\u884c\u57fa\u51c6\u6d4b\u8bd5\u663e\u793a\u4e86 5 \u500d\u7684\u6539\u8fdb\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"104\">\u66f4\u6539\u524d\uff1a<\/td>\n<td width=\"104\">\u65b9\u6cd5<\/td>\n<td width=\"104\">\u5747\u503c<\/td>\n<td width=\"104\">\u9519\u8bef<\/td>\n<td width=\"104\">\u6807\u51c6\u5dee<\/td>\n<td width=\"104\">\u64cd\u4f5c\/\u79d2<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">DecodeHeaderFieldLine_Static_Multiple<\/td>\n<td width=\"104\">235.32 ns<\/td>\n<td width=\"104\">2.981 ns<\/td>\n<td width=\"104\">2.788 ns<\/td>\n<td width=\"104\">4,249,586.2<\/td>\n<td width=\"104\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"104\">\u66f4\u6539\u540e\uff1a<\/td>\n<td width=\"104\">\u65b9\u6cd5<\/td>\n<td width=\"104\">\u5747\u503c<\/td>\n<td width=\"104\">\u9519\u8bef<\/td>\n<td width=\"104\">\u6807\u51c6\u5dee<\/td>\n<td width=\"104\">\u64cd\u4f5c\/\u79d2<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">DecodeHeaderFieldLine_Static_Multiple<\/td>\n<td width=\"104\">45.47 ns<\/td>\n<td width=\"104\">0.556 ns<\/td>\n<td width=\"104\">0.520 ns<\/td>\n<td width=\"104\">21,992,040.2<\/td>\n<td width=\"104\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u5176\u4ed6<\/strong><\/p>\n<p><strong>SignalR <\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/41465\">dotnet\/aspnetcore#41465<\/a> \u786e\u5b9a\u4e86 <a href=\"https:\/\/learn.microsoft.com\/aspnet\/core\/signalr\/introduction\">SignalR<\/a> \u4e2d\u7684\u4e00\u4e2a\u533a\u57df\uff0c\u6211\u4eec\u5728\u8be5\u533a\u57df\u4e2d\u4e00\u904d\u53c8\u4e00\u904d\u5730\u5206\u914d\u76f8\u540c\u7684\u5b57\u7b26\u4e32\u3002 \u901a\u8fc7\u7f13\u5b58\u5b57\u7b26\u4e32\u5e76\u5c06\u5b83\u4eec\u4e0e\u539f\u59cb <span style=\"color: #ff0000;\">Span&lt;byte&gt;<\/span> \u8fdb\u884c\u6bd4\u8f83\u6765\u5220\u9664\u5206\u914d\u3002 \u8be5\u66f4\u6539\u786e\u5b9e\u4f7f\u4ee3\u7801\u8def\u5f84\u96f6\u5206\u914d\uff0c\u4f46\u5b83\u4f7f\u5fae\u57fa\u51c6\u6d4b\u8bd5\u6162\u4e86\u51e0\u7eb3\u79d2\uff08\u8fd9\u53ef\u80fd\u5f88\u597d\uff0c\u56e0\u4e3a\u6211\u4eec\u6b63\u5728\u964d\u4f4e\u5b8c\u6574\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 GC \u538b\u529b\uff09\u3002 \u5c3d\u7ba1\u5982\u6b64\uff0c\u6211\u4eec\u5bf9\u6b64\u5e76\u4e0d\u5b8c\u5168\u6ee1\u610f\uff0c\u56e0\u6b64 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/41644\">dotnet\/aspnetcore#41644<\/a> \u6539\u8fdb\u4e86\u4fee\u6539\u3002 \u5b83\u5047\u5b9a\u533a\u5206\u5927\u5c0f\u5199\u7684\u6bd4\u8f83\u5c06\u662f\u6700\u5e38\u89c1\u7684\uff08\u5728\u6b64\u7528\u4f8b\u4e2d\u5e94\u8be5\u5982\u6b64\uff09\uff0c\u5e76\u5728\u8fdb\u884c\u76f8\u540c\u5927\u5c0f\u5199\u6bd4\u8f83\u65f6\u907f\u514d\u4f7f\u7528 UTF8 \u7f16\u7801\u3002 .NET 7 \u4ee3\u7801\u73b0\u5728\u53ef\u4ee5\u514d\u8d39\u4e14\u66f4\u5feb\u5730\u5206\u914d\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"104\">\u65b9\u6cd5<\/td>\n<td width=\"104\">\u610f\u601d<\/td>\n<td width=\"104\">\u9519\u8bef<\/td>\n<td width=\"104\">\u6807\u51c6\u5dee<\/td>\n<td width=\"104\">\u7b2c0\u4ee3<\/td>\n<td width=\"104\">\u5df2\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">StringLookup<\/td>\n<td width=\"104\">100.19 ns<\/td>\n<td width=\"104\">1.343 ns<\/td>\n<td width=\"104\">1.256 ns<\/td>\n<td width=\"104\">0.0038<\/td>\n<td width=\"104\">32B<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">Utf8LookupBefore<\/td>\n<td width=\"104\">109.24 ns<\/td>\n<td width=\"104\">2.243 ns<\/td>\n<td width=\"104\">2.203 ns<\/td>\n<td width=\"104\">\u2013<\/td>\n<td width=\"104\">\u2013<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">Utf8LookupAfter<\/td>\n<td width=\"104\">85.20 ns<\/td>\n<td width=\"104\">0.831 ns<\/td>\n<td width=\"104\">0.777 ns<\/td>\n<td width=\"104\">\u2013<\/td>\n<td width=\"104\">\u2013<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>Auth<\/strong><\/p>\n<p>\u6765\u81ea<a href=\"https:\/\/github.com\/Kahbazi\">@Kahbazi<\/a> \u4e2d\u7684 <a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/43210\">dotnet\/aspnetcore#43210<\/a> \u7f13\u5b58\u4e86 <span style=\"color: #ff0000;\">PolicyAuthorizationResult<\/span>\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u5e76\u4e14\u5728\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5b83\u4eec\u662f\u4f7f\u7528\u76f8\u540c\u7684\u5c5e\u6027\u521b\u5efa\u7684\u3002 \u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u7b80\u5316\u7684\u57fa\u51c6\u6d4b\u8bd5\u6765\u4e86\u89e3\u8fd9\u6709\u591a\u6709\u6548\u3002<\/p>\n<p>[MemoryDiagnoser]public class CachedBenchmark{\u00a0\u00a0\u00a0 private static readonly object _cachedObject = new object();\u00a0\u00a0\u00a0\u00a0 [Benchmark]\u00a0\u00a0\u00a0 public object GetObject()\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return new object();\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0 [Benchmark]\u00a0\u00a0\u00a0 public object GetCachedObject()\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return _cachedObject;\u00a0\u00a0\u00a0 }}<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"104\">\u65b9\u6cd5<\/td>\n<td width=\"104\">\u5747\u503c<\/td>\n<td width=\"104\">\u9519\u8bef<\/td>\n<td width=\"104\">\u6807\u51c6\u5dee<\/td>\n<td width=\"104\">\u7b2c0\u4ee3<\/td>\n<td width=\"104\">\u5df2\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">GetObject<\/td>\n<td width=\"104\">3.5884 ns<\/td>\n<td width=\"104\">0.0488 ns<\/td>\n<td width=\"104\">0.0432 ns<\/td>\n<td width=\"104\">0.0029<\/td>\n<td width=\"104\">24B<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">GetCachedObject<\/td>\n<td width=\"104\">0.7896 ns<\/td>\n<td width=\"104\">0.0439 ns<\/td>\n<td width=\"104\">0.0389 ns<\/td>\n<td width=\"104\">\u2013<\/td>\n<td width=\"104\">\u2013<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/43268\">dotnet\/aspnetcore#43268<\/a>\uff0c\u540c\u6837\u6765\u81ea<a href=\"https:\/\/github.com\/Kahbazi\">@Kahbazi<\/a>\uff0c\u5bf9 Authentication \u4e2d\u7684\u591a\u79cd\u7c7b\u578b\u5e94\u7528\u4e86\u76f8\u540c\u7684\u66f4\u6539\uff0c\u5e76\u5728\u89e3\u6790\u6388\u6743\u7b56\u7565\u65f6\u989d\u5916\u6dfb\u52a0\u4e86 Task&lt;AuthorizationPolicy&gt; \u7684\u7f13\u5b58\u3002 \u670d\u52a1\u5668\u5728\u542f\u52a8\u65f6\u4e86\u89e3\u6388\u6743\u7b56\u7565\uff0c\u56e0\u6b64\u5b83\u53ef\u4ee5\u9884\u5148\u521b\u5efa\u6240\u6709\u4efb\u52a1\u5e76\u4fdd\u5b58\u6bcf\u4e2a\u8bf7\u6c42\u7684\u4efb\u52a1\u5206\u914d\u3002<\/p>\n<pre class=\"prettyprint\">[MemoryDiagnoser]\r\npublic class CachedBenchmark\r\n{\r\n    private static readonly object _cachedObject = new object();\r\n\r\n    [Benchmark]\r\n    public object GetObject()\r\n    {\r\n        return new object();\r\n    }\r\n\r\n    [Benchmark]\r\n    public object GetCachedObject()\r\n    {\r\n        return _cachedObject;\r\n    }\r\n}<\/pre>\n<table>\n<tbody>\n<tr>\n<td width=\"89\">\u65b9\u6cd5<\/td>\n<td width=\"89\">\u5747\u503c<\/td>\n<td width=\"89\">\u9519\u8bef<\/td>\n<td width=\"89\">\u6807\u51c6\u5dee<\/td>\n<td width=\"89\">\u6bd4\u7387<\/td>\n<td width=\"89\">\u7b2c0\u4ee3<\/td>\n<td width=\"89\">\u5df2\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td width=\"89\">GetTask<\/td>\n<td width=\"89\">22.59 ns<\/td>\n<td width=\"89\">0.322 ns<\/td>\n<td width=\"89\">0.285 ns<\/td>\n<td width=\"89\">1.00<\/td>\n<td width=\"89\">0.0092<\/td>\n<td width=\"89\">72B<\/td>\n<\/tr>\n<tr>\n<td width=\"89\">GetCachedTask<\/td>\n<td width=\"89\">11.70 ns<\/td>\n<td width=\"89\">0.065 ns<\/td>\n<td width=\"89\">0.055 ns<\/td>\n<td width=\"89\">0.52<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\">\u2013<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/43124\">dotnet\/aspnetcore#43124<\/a> \u5c06\u7f13\u5b58\u6dfb\u52a0\u5230\u6388\u6743\u4e2d\u95f4\u4ef6\uff0c\u8fd9\u5c06\u907f\u514d\u9488\u5bf9\u6bcf\u4e2a\u7aef\u70b9\u7684\u6bcf\u4e2a\u8bf7\u6c42\u91cd\u65b0\u8ba1\u7b97\u7ec4\u5408\u7684 AuthorizationPolicy\u3002 \u56e0\u4e3a\u7aef\u70b9\u5728\u542f\u52a8\u540e\u901a\u5e38\u4fdd\u6301\u4e0d\u53d8\uff0c\u6211\u4eec\u4e0d\u9700\u8981\u4e3a\u6bcf\u4e2a\u8bf7\u6c42\u4ece\u7aef\u70b9\u83b7\u53d6\u6388\u6743\u5143\u6570\u636e\u5e76\u5c06\u5b83\u4eec\u7ec4\u5408\u6210\u4e00\u4e2a\u7b56\u7565\u3002 \u76f8\u53cd\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u9996\u6b21\u8bbf\u95ee\u7aef\u70b9\u65f6\u7f13\u5b58\u7ec4\u5408\u7b56\u7565\u3002 \u5982\u679c\u60a8\u5b9e\u73b0\u81ea\u5b9a\u4e49 IAuthorizationPolicyProvider \u53ef\u4ee5\u663e\u7740\u8282\u7701\u7f13\u5b58\uff0c\u8fd9\u4e9b IAuthorizationPolicyProvider \u5177\u6709\u6602\u8d35\u7684\u64cd\u4f5c\uff0c\u5982\u6570\u636e\u5e93\u8bbf\u95ee\uff0c\u5e76\u4e14\u53ea\u9700\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u751f\u547d\u5468\u671f\u5185\u8fd0\u884c\u4e00\u6b21\u3002<\/p>\n<p><strong>HttpResult<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/40965\">dotnet\/aspnetcore#40965<\/a> \u662f\u63a2\u7d22\u591a\u6761\u8def\u7531\u4ee5\u5b9e\u73b0\u66f4\u597d\u6027\u80fd\u7684\u7edd\u4f73\u793a\u4f8b\u3002 \u76ee\u6807\u662f\u7f13\u5b58 HttpResult \u7c7b\u578b\u3002 \u5927\u591a\u6570\u7ed3\u679c\u7c7b\u578b\u7c7b\u4f3c\u4e8e UnauthorizedHttpResult\uff0c\u5b83\u6ca1\u6709\u53c2\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u6b21\u9759\u6001\u5b9e\u4f8b\u5e76\u59cb\u7ec8\u8fd4\u56de\u5b83\u6765\u7f13\u5b58\u3002 \u4e00\u4e2a\u66f4\u6709\u8da3\u7684\u7ed3\u679c\u662f StatusCodeHttpResult\uff0c\u53ef\u4ee5\u7ed9\u5b83\u4efb\u4f55\u6574\u6570\u6765\u8868\u793a\u8fd4\u56de\u7ed9\u8c03\u7528\u8005\u7684\u72b6\u6001\u7801\u3002 PR \u63a2\u7d22\u4e86\u591a\u79cd\u7f13\u5b58 StatusCodeHttpResult \u5bf9\u8c61\u7684\u65b9\u6cd5\uff0c\u5e76\u5c55\u793a\u4e86\u6bcf\u79cd\u65b9\u6cd5\u7684\u6027\u80fd\u6570\u636e\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"89\">\u5df2\u77e5\u72b6\u6001\u7801\uff08\u4f8b\u5982 200\uff09\uff1a<\/td>\n<td width=\"89\">\u65b9\u6cd5<\/td>\n<td width=\"89\">\u5747\u503c<\/td>\n<td width=\"89\">\u9519\u8bef<\/td>\n<td width=\"89\">\u6807\u51c6\u5dee<\/td>\n<td width=\"89\">0\u4ee3<\/td>\n<td width=\"89\">\u5df2\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td width=\"89\">NoCache<\/td>\n<td width=\"89\">2.725 ns<\/td>\n<td width=\"89\">0.0285 ns<\/td>\n<td width=\"89\">0.0253 ns<\/td>\n<td width=\"89\">0.0001<\/td>\n<td width=\"89\">24B<\/td>\n<td width=\"89\"><\/td>\n<\/tr>\n<tr>\n<td width=\"89\">StaticCacheWithDictionary<\/td>\n<td width=\"89\">5.733 ns<\/td>\n<td width=\"89\">0.0373 ns<\/td>\n<td width=\"89\">0.0331 ns<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\"><\/td>\n<\/tr>\n<tr>\n<td width=\"89\">DynamicCacheWithFixedSizeArray<\/td>\n<td width=\"89\">2.184 ns<\/td>\n<td width=\"89\">0.0227 ns<\/td>\n<td width=\"89\">0.0212 ns<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\"><\/td>\n<\/tr>\n<tr>\n<td width=\"89\">DynamicCacheWithFixedSizeArrayPerStatusGroup<\/td>\n<td width=\"89\">3.371 ns<\/td>\n<td width=\"89\">0.0151 ns<\/td>\n<td width=\"89\">0.0134 ns<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\"><\/td>\n<\/tr>\n<tr>\n<td width=\"89\">DynamicCacheWithConcurrentDictionary<\/td>\n<td width=\"89\">5.450 ns<\/td>\n<td width=\"89\">0.1495 ns<\/td>\n<td width=\"89\">0.1468 ns<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\"><\/td>\n<\/tr>\n<tr>\n<td width=\"89\">StaticCacheWithSwitchExpression<\/td>\n<td width=\"89\">1.867 ns<\/td>\n<td width=\"89\">0.0045 ns<\/td>\n<td width=\"89\">0.0042 ns<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\"><\/td>\n<\/tr>\n<tr>\n<td width=\"89\">DynamicCacheWithSwitchExpression<\/td>\n<td width=\"89\">1.889 ns<\/td>\n<td width=\"89\">0.0143 ns<\/td>\n<td width=\"89\">0.0119 ns<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\">\u2013<\/td>\n<td width=\"89\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"313\">\u672a\u77e5\u72b6\u6001\u7801\uff08\u4f8b\u5982 150\uff09\uff1a<\/td>\n<td width=\"71\">\u65b9\u6cd5<\/td>\n<td width=\"58\">\u5747\u503c<\/td>\n<td width=\"55\">\u9519\u8bef<\/td>\n<td width=\"57\">\u6807\u51c6\u5dee<\/td>\n<td width=\"38\">0\u4ee3<\/td>\n<td width=\"32\">\u5df2\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td width=\"313\">NoCache<\/td>\n<td width=\"71\">2.477 ns<\/td>\n<td width=\"58\">0.0818 ns<\/td>\n<td width=\"55\">0.1005 ns<\/td>\n<td width=\"57\">0.0001<\/td>\n<td width=\"38\">24B<\/td>\n<td rowspan=\"7\" width=\"32\"><\/td>\n<\/tr>\n<tr>\n<td width=\"313\">StaticCacheWithDictionary<\/td>\n<td width=\"71\">8.479 ns<\/td>\n<td width=\"58\">0.0650 ns<\/td>\n<td width=\"55\">0.0576 ns<\/td>\n<td width=\"57\">0.0001<\/td>\n<td width=\"38\">24B<\/td>\n<\/tr>\n<tr>\n<td width=\"313\">DynamicCacheWithFixedSizeArray<\/td>\n<td width=\"71\">2.234 ns<\/td>\n<td width=\"58\">0.0361 ns<\/td>\n<td width=\"55\">0.0302 ns<\/td>\n<td width=\"57\">\u2013<\/td>\n<td width=\"38\">\u2013<\/td>\n<\/tr>\n<tr>\n<td width=\"313\">DynamicCacheWithFixedSizeArrayPerStatusGroup<\/td>\n<td width=\"71\">4.809 ns<\/td>\n<td width=\"58\">0.0360 ns<\/td>\n<td width=\"55\">0.0281 ns<\/td>\n<td width=\"57\">0.0001<\/td>\n<td width=\"38\">24B<\/td>\n<\/tr>\n<tr>\n<td width=\"313\">DynamicCacheWithConcurrentDictionary<\/td>\n<td width=\"71\">6.076 ns<\/td>\n<td width=\"58\">0.0672 ns<\/td>\n<td width=\"55\">0.0595 ns<\/td>\n<td width=\"57\">\u2013<\/td>\n<td width=\"38\">\u2013<\/td>\n<\/tr>\n<tr>\n<td width=\"313\">StaticCacheWithSwitchExpression<\/td>\n<td width=\"71\">4.195 ns<\/td>\n<td width=\"58\">0.0823 ns<\/td>\n<td width=\"55\">0.0770 ns<\/td>\n<td width=\"57\">0.0001<\/td>\n<td width=\"38\">24B<\/td>\n<\/tr>\n<tr>\n<td width=\"313\">DynamicCacheWithSwitchExpression<\/td>\n<td width=\"71\">4.146 ns<\/td>\n<td width=\"58\">0.0401 ns<\/td>\n<td width=\"55\">0.0335 ns<\/td>\n<td width=\"57\">0.0001<\/td>\n<td width=\"38\">24B<\/p>\n<p>&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6211\u4eec\u6700\u7ec8\u9009\u62e9\u4e86\u201cStaticCacheWithSwitchExpression\u201d\uff0c\u5b83\u4f7f\u7528 <a href=\"https:\/\/learn.microsoft.com\/visualstudio\/modeling\/code-generation-and-t4-text-templates\">T4 \u6a21\u677f<\/a>\u4e3a\u4f17\u6240\u5468\u77e5\u7684\u72b6\u6001\u4ee3\u7801\u751f\u6210\u7f13\u5b58\u5b57\u6bb5\uff0c\u5e76\u4f7f\u7528 switch \u8868\u8fbe\u5f0f\u8fd4\u56de\u5b83\u4eec\u3002 \u8fd9\u79cd\u65b9\u6cd5\u4e3a\u5df2\u77e5\u72b6\u6001\u4ee3\u7801\u63d0\u4f9b\u4e86\u6700\u4f73\u6027\u80fd\uff0c\u8fd9\u5c06\u662f\u5927\u591a\u6570\u5e94\u7528\u7a0b\u5e8f\u7684\u5e38\u89c1\u60c5\u51b5\u3002<\/p>\n<p><strong>IndexOfAny<\/strong><\/p>\n<p>\u6765\u81ea@martincostello \u7684<a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/39743\">dotnet\/aspnetcore#39743<\/a> \u6ce8\u610f\u5230\u6211\u4eec\u5c06\u957f\u5ea6\u4e3a2 \u7684<span style=\"color: #ff0000;\">char[]<\/span> \u4f20\u9012\u7ed9<span style=\"color: #ff0000;\">string.IndexOfAny<\/span> \u7684\u4e00\u4e9b\u5730\u65b9\u3002 char \u6570\u7ec4\u91cd\u8f7d\u6bd4\u5c06 2 \u4e2a\u5b57\u7b26\u76f4\u63a5\u4f20\u9012\u7ed9 <span style=\"color: #ff0000;\">ReadOnlySpan&lt;char&gt;.IndexOfAny<\/span> \u65b9\u6cd5\u8981\u6162\u3002 \u6b64\u66f4\u6539\u66f4\u65b0\u4e86\u591a\u4e2a\u8c03\u7528\u7ad9\u70b9\u4ee5\u5220\u9664 <span style=\"color: #ff0000;\">char[]<\/span> \u5e76\u4f7f\u7528\u66f4\u5feb\u7684\u65b9\u6cd5\u3002 \u8bf7\u6ce8\u610f\uff0c<span style=\"color: #ff0000;\">IndexOfAny<\/span> \u4e3a 2 \u548c 3 \u4e2a\u5b57\u7b26\u63d0\u4f9b\u6b64\u65b9\u6cd5\u3002<\/p>\n<pre class=\"prettyprint\">public class IndexOfAnyBenchmarks\r\n{\r\n    private const string AUrlWithAPathAndQueryString = \"http:\/\/www.example.com\/path\/to\/file.html?query=string\";\r\n    private static readonly char[] QueryStringAndFragmentTokens = new[] { '?', '#' };\r\n\r\n    [Benchmark(Baseline = true)]\r\n    public int IndexOfAny_String()\r\n    {\r\n        return AUrlWithAPathAndQueryString.IndexOfAny(QueryStringAndFragmentTokens);\r\n    }\r\n\r\n    [Benchmark]\r\n    public int IndexOfAny_Span_Array()\r\n    {\r\n        return AUrlWithAPathAndQueryString.AsSpan().IndexOfAny(QueryStringAndFragmentTokens);\r\n    }\r\n\r\n    [Benchmark]\r\n    public int IndexOfAny_Span_Two_Chars()\r\n    {\r\n        return AUrlWithAPathAndQueryString.AsSpan().IndexOfAny('?', '#');\r\n    }\r\n}<\/pre>\n<table>\n<tbody>\n<tr>\n<td width=\"125\">\u65b9\u6cd5<\/td>\n<td width=\"125\">\u5747\u503c<\/td>\n<td width=\"125\">\u9519\u8bef<\/td>\n<td width=\"125\">\u6807\u51c6\u5dee<\/td>\n<td width=\"125\">\u6bd4\u7387<\/td>\n<\/tr>\n<tr>\n<td width=\"125\">IndexOfAny_String<\/td>\n<td width=\"125\">7.004 ns<\/td>\n<td width=\"125\">0.1166 ns<\/td>\n<td width=\"125\">0.1091 ns<\/td>\n<td width=\"125\">1.00<\/td>\n<\/tr>\n<tr>\n<td width=\"125\">IndexOfAny_Span_Array<\/td>\n<td width=\"125\">6.847 ns<\/td>\n<td width=\"125\">0.0371 ns<\/td>\n<td width=\"125\">0.0347 ns<\/td>\n<td width=\"125\">0.98<\/td>\n<\/tr>\n<tr>\n<td width=\"125\">IndexOfAny_Span_Two_Chars<\/td>\n<td width=\"125\">5.161 ns<\/td>\n<td width=\"125\">0.0697 ns<\/td>\n<td width=\"125\">0.0582 ns<\/td>\n<td width=\"125\">0.73<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u8fc7\u6ee4\u5668<\/strong><\/p>\n<p>\u5728 .NET 7 \u4e2d\uff0c\u6211\u4eec\u4e3a Minimal API \u5f15\u5165\u4e86\u8fc7\u6ee4\u5668\u3002 \u5728\u8bbe\u8ba1\u8be5\u529f\u80fd\u65f6\uff0c\u6211\u4eec\u975e\u5e38\u6ce8\u91cd\u6027\u80fd\u3002 \u6211\u4eec\u5728\u9884\u89c8\u671f\u95f4\u5206\u6790\u4e86\u8fc7\u6ee4\u5668\uff0c\u4ee5\u627e\u5230\u5728\u529f\u80fd\u521d\u59cb\u5408\u5e76\u540e\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u6027\u80fd\u7684\u9886\u57df\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/41740\">dotnet\/aspnetcore#41740<\/a> \u4fee\u590d\u4e86\u6211\u4eec\u5728\u4f7f\u7528\u8fc7\u6ee4\u5668\u65f6\u4e3a\u6bcf\u4e2a\u5bf9\u65e0\u53c2\u6570\u7aef\u70b9\u7684\u8bf7\u6c42\u5206\u914d\u4e00\u4e2a\u7a7a\u6570\u7ec4\u7684\u60c5\u51b5\u3002 \u8fd9\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 Array.Empty&lt;object&gt;() \u800c\u4e0d\u662f new object[0] \u6765\u89e3\u51b3\u3002 \u8fd9\u4f3c\u4e4e\u5f88\u660e\u663e\uff0c\u4f46\u662f\u5728<a href=\"https:\/\/learn.microsoft.com\/dotnet\/csharp\/programming-guide\/concepts\/expression-trees\/\">\u7f16\u5199\u8868\u8fbe\u5f0f\u6811<\/a>\u65f6\uff0c\u8fd9\u5f88\u5bb9\u6613\u505a\u5230\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/aspnetcore\/pull\/41379\">dotnet\/aspnetcore#41379<\/a> \u5220\u9664\u4e86 Minimal API \u4e2d ValueTask&lt;object&gt; \u8fd4\u56de\u65b9\u6cd5\u7684<a href=\"https:\/\/learn.microsoft.com\/dotnet\/csharp\/programming-guide\/types\/boxing-and-unboxing\">\u88c5\u7bb1<\/a>\u5206\u914d\uff0c\u8fd9\u662f\u7528\u4e8e\u5305\u88c5\u7528\u6237\u63d0\u4f9b\u7684\u59d4\u6258\u7684\u8fc7\u6ee4\u5668\u3002 \u5220\u9664\u88c5\u7bb1\u4f7f\u5f97\u6dfb\u52a0\u8fc7\u6ee4\u5668\u7684\u552f\u4e00\u5f00\u9500\u662f\u5206\u914d\u4e00\u4e2a\u4e0a\u4e0b\u6587\u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u5141\u8bb8\u7528\u6237\u4ee3\u7801\u68c0\u67e5\u4ece\u8bf7\u6c42\u5230\u5176\u7aef\u70b9\u7684\u53c2\u6570\u3002<\/p>\n<p><a href=\"dotnet\/aspnetcore#41406\">dotnet\/aspnetcore#41406<\/a> \u901a\u8fc7\u5728\u7aef\u70b9\u4e2d\u6dfb\u52a0 1 \u5230 10 \u4e2a\u53c2\u6570,\u53c2\u6570\u7684\u901a\u7528\u7c7b\u5b9e\u73b0\u6539\u8fdb\u4e86\u521b\u5efa\u8fc7\u6ee4\u4e0a\u4e0b\u6587\u5bf9\u8c61\u7684\u5206\u914d\u3002 \u6b64\u66f4\u6539\u907f\u514d\u4e86\u7528\u4e8e\u4fdd\u5b58\u53c2\u6570\u503c\u7684 object[] \u5206\u914d\u4ee5\u53ca\u4f7f\u7528\u7ed3\u6784\u53c2\u6570\u65f6\u53ef\u80fd\u53d1\u751f\u7684\u4efb\u4f55\u88c5\u7bb1\u3002 \u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u7b80\u5316\u7684\u793a\u4f8b\u6765\u663e\u793a\u6539\u8fdb\uff1a<\/p>\n<pre class=\"prettyprint\">[MemoryDiagnoser]\r\npublic class FilterContext\r\n{\r\n    internal abstract class Context\r\n    {\r\n        public abstract T GetArgument&lt;T&gt;(int index);\r\n    }\r\n\r\n    internal sealed class DefaultContext : Context\r\n    {\r\n        public DefaultContext(params object[] arguments)\r\n        {\r\n            Arguments = arguments;\r\n        }\r\n\r\n        private IList&lt;object?&gt; Arguments { get; }\r\n\r\n        public override T GetArgument&lt;T&gt;(int index)\r\n        {\r\n            return (T)Arguments[index]!;\r\n        }\r\n    }\r\n\r\n    internal sealed class Context&lt;T0&gt; : Context\r\n    {\r\n        public Context(T0 argument)\r\n        {\r\n            Arg0 = argument;\r\n        }\r\n\r\n        public T0 Arg0 { get; set; }\r\n\r\n        public override T GetArgument&lt;T&gt;(int index)\r\n        {\r\n            return index switch\r\n            {\r\n                0 =&gt; (T)(object)Arg0!,\r\n                _ =&gt; throw new IndexOutOfRangeException()\r\n            };\r\n        }\r\n    }\r\n\r\n    [Benchmark]\r\n    public TimeSpan GetArgBoxed()\r\n    {\r\n        var defaultContext = new DefaultContext(new TimeSpan());\r\n        return defaultContext.GetArgument&lt;TimeSpan&gt;(0);\r\n    }\r\n\r\n    [Benchmark]\r\n    public TimeSpan GetArg()\r\n    {\r\n        var typedContext = new Context&lt;TimeSpan&gt;(new TimeSpan());\r\n        return typedContext.GetArgument&lt;TimeSpan&gt;(0);\r\n    }\r\n}<\/pre>\n<table>\n<tbody>\n<tr>\n<td width=\"104\">\u65b9\u6cd5<\/td>\n<td width=\"104\">\u5747\u503c<\/td>\n<td width=\"104\">\u9519\u8bef<\/td>\n<td width=\"104\">\u6807\u51c6\u5dee<\/td>\n<td width=\"104\">\u7b2c0\u4ee3<\/td>\n<td width=\"104\">\u5df2\u5206\u914d<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">GetArgBoxed<\/td>\n<td width=\"104\">16.865 ns<\/td>\n<td width=\"104\">0.1878 ns<\/td>\n<td width=\"104\">0.1466 ns<\/td>\n<td width=\"104\">0.0102<\/td>\n<td width=\"104\">80B<\/td>\n<\/tr>\n<tr>\n<td width=\"104\">GetArg<\/td>\n<td width=\"104\">3.292 ns<\/td>\n<td width=\"104\">0.0806 ns<\/td>\n<td width=\"104\">0.0792 ns<\/td>\n<td width=\"104\">0.0031<\/td>\n<td width=\"104\">24B<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\n<\/strong><strong>\u603b\u7ed3<\/strong><\/p>\n<p>\u8bf7\u8bd5\u7528 .NET 7\uff0c\u8ba9\u6211\u4eec\u77e5\u9053\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u53d1\u751f\u4e86\u600e\u6837\u7684\u53d8\u5316\uff01 \u6211\u4eec\u4e00\u76f4\u5728\u5bfb\u627e\u6709\u5173\u5982\u4f55\u6539\u8fdb\u4ea7\u54c1\u7684\u53cd\u9988\uff0c\u5e76\u671f\u5f85\u60a8\u7684\u8d21\u732e\uff0c\u65e0\u8bba\u662f\u95ee\u9898\u62a5\u544a\u8fd8\u662f PR\u3002 \u5982\u679c\u60a8\u60f3\u8981\u66f4\u591a\u7684\u6027\u80fd\u4f18\u52bf\uff0c\u60a8\u53ef\u4ee5\u9605\u8bfb <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/performance_improvements_in_net_7\/\">.NET 7 \u4e2d\u7684\u6027\u80fd\u6539\u8fdb<\/a>\u5e16\u5b50\u3002 \u6b64\u5916\uff0c\u8bf7\u67e5\u770b<a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/category\/developer-stories\/\">\u5f00\u53d1\u4eba\u5458\u6545\u4e8b<\/a>\uff0c\u5176\u4e2d\u5c55\u793a\u4e86 Microsoft \u7684\u591a\u4e2a\u56e2\u961f\u4ece .NET Framework \u8fc1\u79fb\u5230 .NET Core \u5e76\u770b\u5230\u4e3b\u8981\u6027\u80fd\u548c <a href=\"https:\/\/www.investopedia.com\/terms\/c\/cogs.asp\">COGS<\/a> \u7684\u80dc\u5229\u3002<\/p>\n<p>\u611f\u8c22\u60a8\u6210\u4e3a.NET\u4e2d\u7684\u4e00\u5458\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u7ffb\u8bd1\u4e8eBrennan Conroy\u7684\u8fd9\u7bc7\u82f1\u6587\u6587\u7ae0\uff1aPerformance improvements in ASP.NET Core 7\u3002 \u6027\u80fd\u662f .NET \u7684\u4e00\u4e2a\u7279\u6027\u3002\u5728\u6bcf\u4e2a\u7248\u672c\u4e2d\uff0c.NET \u56e2\u961f\u548c\u793e\u533a\u8d21\u732e\u8005\u90fd\u4f1a\u82b1\u65f6\u95f4\u6539\u8fdb\u6027\u80fd\uff0c\u4e3a\u7684\u662f\u4f7f.NET \u5e94\u7528\u7a0b\u5e8f\u66f4\u5feb\u5e76\u4e14\u4f7f\u7528\u66f4\u5c11\u7684\u8d44\u6e90\u3002 \u8fd9\u7bc7\u535a\u6587\u91cd\u70b9\u4ecb\u7ecd\u4e86 ASP.NET Core 7 \u4e2d\u7684\u4e00\u4e9b\u6027\u80fd\u6539\u8fdb\u3002\u8fd9\u662f\u53bb\u5e74\u5173\u4e8e ASP.NET Core 6 \u6027\u80fd\u6539\u8fdb\u7684\u6587\u7ae0\u7684\u5ef6\u7eed\u3002\u5f53\u7136\uff0c\u5b83\u7ee7\u7eed\u53d7\u5230 .NET 7 \u4e2d\u7684\u6027\u80fd\u6539\u8fdb\u7684\u542f\u53d1\u3002\u5176\u4e2d\u8bb8\u591a\u6539\u8fdb\u95f4\u63a5\u6216\u76f4\u63a5\u5730\u63d0\u9ad8\u4e86 ASP.NET Core \u7684\u6027\u80fd\u3002 \u57fa\u51c6\u8bbe\u7f6e \u6211\u4eec\u5c06\u5728\u8fd9\u7bc7\u535a\u6587\u4e2d\u7684\u5927\u90e8\u5206\u793a\u4f8b\u4e2d\u4f7f\u7528 BenchmarkDotNet\u3002 \u9996\u5148\u8bbe\u7f6e\u57fa\u51c6\u6d4b\u8bd5\u9879\u76ee\uff1a \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\uff08dotnet new console\uff09 \u6dfb\u52a0\u5bf9 BenchmarkDotnet \u7684 Nuget \u5f15\u7528\uff08dotnet add package BenchmarkDotnet\uff09version 0.13.2+ \u5c06Program.cs \u66f4\u6539\u4e3a var summary = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(); \u5728\u4e0b\u9762\u6dfb\u52a0\u60a8\u8981\u8fd0\u884c\u7684\u57fa\u51c6\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5 \u8fd0\u884c dotnet run -c Release [&hellip;]<\/p>\n","protected":false},"author":99475,"featured_media":156,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[2,6],"class_list":["post-152","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet-ch","tag-net","tag-asp-net"],"acf":[],"blog_post_summary":"<p>\u672c\u6587\u7ffb\u8bd1\u4e8eBrennan Conroy\u7684\u8fd9\u7bc7\u82f1\u6587\u6587\u7ae0\uff1aPerformance improvements in ASP.NET Core 7\u3002 \u6027\u80fd\u662f .NET \u7684\u4e00\u4e2a\u7279\u6027\u3002\u5728\u6bcf\u4e2a\u7248\u672c\u4e2d\uff0c.NET \u56e2\u961f\u548c\u793e\u533a\u8d21\u732e\u8005\u90fd\u4f1a\u82b1\u65f6\u95f4\u6539\u8fdb\u6027\u80fd\uff0c\u4e3a\u7684\u662f\u4f7f.NET \u5e94\u7528\u7a0b\u5e8f\u66f4\u5feb\u5e76\u4e14\u4f7f\u7528\u66f4\u5c11\u7684\u8d44\u6e90\u3002 \u8fd9\u7bc7\u535a\u6587\u91cd\u70b9\u4ecb\u7ecd\u4e86 ASP.NET Core 7 \u4e2d\u7684\u4e00\u4e9b\u6027\u80fd\u6539\u8fdb\u3002\u8fd9\u662f\u53bb\u5e74\u5173\u4e8e ASP.NET Core 6 \u6027\u80fd\u6539\u8fdb\u7684\u6587\u7ae0\u7684\u5ef6\u7eed\u3002\u5f53\u7136\uff0c\u5b83\u7ee7\u7eed\u53d7\u5230 .NET 7 \u4e2d\u7684\u6027\u80fd\u6539\u8fdb\u7684\u542f\u53d1\u3002\u5176\u4e2d\u8bb8\u591a\u6539\u8fdb\u95f4\u63a5\u6216\u76f4\u63a5\u5730\u63d0\u9ad8\u4e86 ASP.NET Core \u7684\u6027\u80fd\u3002 \u57fa\u51c6\u8bbe\u7f6e \u6211\u4eec\u5c06\u5728\u8fd9\u7bc7\u535a\u6587\u4e2d\u7684\u5927\u90e8\u5206\u793a\u4f8b\u4e2d\u4f7f\u7528 BenchmarkDotNet\u3002 \u9996\u5148\u8bbe\u7f6e\u57fa\u51c6\u6d4b\u8bd5\u9879\u76ee\uff1a \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\uff08dotnet new console\uff09 \u6dfb\u52a0\u5bf9 BenchmarkDotnet \u7684 Nuget \u5f15\u7528\uff08dotnet add package BenchmarkDotnet\uff09version 0.13.2+ \u5c06Program.cs \u66f4\u6539\u4e3a var summary = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(); \u5728\u4e0b\u9762\u6dfb\u52a0\u60a8\u8981\u8fd0\u884c\u7684\u57fa\u51c6\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5 \u8fd0\u884c dotnet run -c Release [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/users\/99475"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/comments?post=152"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/posts\/152\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/media\/156"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/media?parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/categories?post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet-ch\/wp-json\/wp\/v2\/tags?post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}