{"id":233133,"date":"2021-06-30T16:06:11","date_gmt":"2021-06-30T23:06:11","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=233133"},"modified":"2021-06-30T16:06:11","modified_gmt":"2021-06-30T23:06:11","slug":"net-object-allocation-tool-performance","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/net-object-allocation-tool-performance\/","title":{"rendered":".NET Object Allocation Tool Performance"},"content":{"rendered":"<p>With the release of Visual Studio 16.10 comes a new analysis engine for the Performance Profiler, with the .NET Object Allocation Tool being the first tool to be onboarded. This provides the tool with some new features and a significant perf boost. Give it a shot with your C# app and see what spurious allocations you can remove to speed up your app!<\/p>\n<h2>What&#8217;s new?<\/h2>\n<p>The .NET Object Allocation Tool now has support for <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/library-guidance\/sourcelink\">Source Link<\/a> which lets the tool pull down source files when going to source. This lets you see exactly where allocations are happening even if they are not in your code.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/SourceLink.gif\"><img decoding=\"async\" class=\"alignnone wp-image-233135 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/SourceLink.gif\" alt=\"Navigate to source via SourceLink\" width=\"991\" height=\"676\" \/><\/a><\/p>\n<p>Search now has auto complete suggestions to help you find and dig through reports quicker.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/AutoComplete.gif\"><img decoding=\"async\" class=\"alignnone wp-image-233136 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/AutoComplete.gif\" alt=\"Search auto complete\" width=\"991\" height=\"676\" \/><\/a><\/p>\n<p>Lastly, we have added additional information to the Collections view to try and give more insights into the <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/garbage-collection\/\">.NET Garbage Collector (GC)<\/a>. You can now see why a GC occurred along with relevant stats such as how long it took, the heap size, and how many objects were collected.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Collected.png\"><img decoding=\"async\" class=\"alignnone wp-image-233137 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Collected.png\" alt=\"Updated collections tab\" width=\"1054\" height=\"751\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Collected.png 1054w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Collected-300x214.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Collected-1024x730.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Collected-768x547.png 768w\" sizes=\"(max-width: 1054px) 100vw, 1054px\" \/><\/a><\/p>\n<h2>Let&#8217;s see some numbers!<\/h2>\n<p>One of the areas we\u2019ve spent the most energy on is improving the performance of .NET Object Allocation Tool. To do that we focused on the two big tasks the tool performs:<\/p>\n<ol>\n<li>Building the initial allocation model which is used to look up allocations for the views.<\/li>\n<li>Building the call tree which is used to show the call tree, functions, and backtrace view.<\/li>\n<\/ol>\n<p>In the table below you can see just have much faster the tool is in the latest version of Visual Studio.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 33.3333%;\"><a href=\"https:\/\/github.com\/davidfowl\/AspNetCoreDiagnosticScenarios\">ASP.NET Scenarios App<\/a><\/td>\n<td style=\"width: 33.3333%; text-align: center;\">Build Allocation Model<\/td>\n<td style=\"width: 33.3333%; text-align: center;\">Build Call Tree<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">Small trace (500K allocations)<\/td>\n<td style=\"width: 33.3333%; text-align: right;\">3.5s -&gt; 2.2s<\/p>\n<p><strong>~1.5x faster<\/strong><\/td>\n<td style=\"width: 33.3333%; text-align: right;\">295s -&gt; 24s<\/p>\n<p><strong>~12x faster<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">Medium trace (1M allocations)<\/td>\n<td style=\"width: 33.3333%; text-align: right;\">6.9s -&gt; 3.6s<\/p>\n<p><strong>~2x faster<\/strong><\/td>\n<td style=\"width: 33.3333%; text-align: right;\">695 -&gt; 58s<\/p>\n<p><strong>~11x faster<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">Large trace (3.1M allocations)<\/td>\n<td style=\"width: 33.3333%; text-align: right;\">22.5s -&gt; 8.4s<\/p>\n<p><strong>~2.5x faster<\/strong><\/td>\n<td style=\"width: 33.3333%; text-align: right;\">1556s -&gt; 109s<\/p>\n<p><strong>~14x faster<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As you can see we are significantly faster, and those numbers aren\u2019t even an apples to apples comparison as the new version does even more analysis but it is still faster than the previous version!<\/p>\n<p>This is just the beginning, the first tool. We are extending these changes to other tools in the Performance Profiler for Visual Studio 2022 and have additional ideas on how we can save even more time. Expect your profiling experience to get a whole lot faster!<\/p>\n<h2>Come chat with us<\/h2>\n<p>We&#8217;d love to hear your feedback. If you&#8217;d like to share your feedback or to chat with our engineering team on how we can improve this tool, please fill out the survey below.<\/p>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/www.surveymonkey.com\/r\/FFYKZWD\" target=\"_blank\">Take the Survey<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the release of Visual Studio 16.10 comes a new analysis engine for the Performance Profiler, with the .NET Object Allocation Tool being the first tool to be onboarded. This provides the tool with some new features and a significant perf boost. Give it a shot with your C# app and see what spurious allocations [&hellip;]<\/p>\n","protected":false},"author":54885,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[],"class_list":["post-233133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio"],"acf":[],"blog_post_summary":"<p>With the release of Visual Studio 16.10 comes a new analysis engine for the Performance Profiler, with the .NET Object Allocation Tool being the first tool to be onboarded. This provides the tool with some new features and a significant perf boost. Give it a shot with your C# app and see what spurious allocations [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/233133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/54885"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=233133"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/233133\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=233133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=233133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=233133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}