While the MVC team is working hard on MVC 6 as part of the ASP.NET 5 effort, we also keep working on the 5.x packages. Today we are releasing a Beta of ASP.NET MVC 5.2.3, Web Pages 5.2.3 and Web API 5.2.3.
This preview release addresses 12 issues. Here is the full list.
Highlight of issues fixed
Web API Issues
2092 Significant performance improvement in the default overload for System.Net.HttpFormatting.ReadAsAsync by caching the default JSON formatter. This can result in improvements of 100s of milliseconds on the second call to ReadAsAsync (or similarly to the write method).
2103 Batch's inner request's Url not being decoded in WebHost scenarios.
2101 Error parsing MIME multipart when using irregular mime types
MVC Issues
2155 Remote attribute does not work boolean fields and Html.CheckBoxFor
2081 Performance improvement in OutputCacheAttribute for child action
2136 Attribute routing does not set ControllerContext.IsChild correctly
2172, 2048– Unobtrusive validation fixes
MVC and Web Pages Issues
2085 Performance improvement in rendering Razor views
2119 Performance improvement in rendering attributes in Razor
Shout Out
We want to convey a big thank you to Marc Gravell, who reported two of the performance issues we resolved in this release and provided a pretty cool Pull Request to fix one of them.
Issue 2085 in detail
Issue 2085 was about the fact the MVC copied ViewData for partial views, and templated helpers. In a reasonably large page with a reasonable amount of data in the ViewBag this proves out to be rather costly. We are now using a copy on write strategy instead. We took this improvement over to MVC 6 as well.
The Test
We built a test site, that put about 50 items in the ViewBag. For each of these items we rendered a partial view. This is similar to having 50 templated helpers (such as DisplayFor and EditorFor) used on a page.
We ran two types of tests:
1. Load the site with a constant stream of requests at the rate of 100 requests/second, and compare memory utilization and garbage collection characteristics for MVC 5.2.2 and MVC 5.2.3.
2. Load the site with maximum amount of requests and compare the requests/second rate between MVC 5.2.2 and MVC 5.2.3.
Results
Test 1
The interesting data in this scenario as the reduction of time spent in GC and reduction in overall allocations. Note that Gen2 garbage collection count went down from 57 to 1! And the time in GC was sliced almost three fold.
Area | 5.2.2 | 5.2.3 | Delta % |
Total request (count) | 2,911 | 2,869 | |
Trace duration (seconds) | 30 | 30 | |
Request/second | 97.03 | 95.63 | |
GC CPU Samples (msec) | 12,139.00 | 6,682.00 | 45% |
Total allocations (MB) | 18,049.79 | 12,602.08 | 30% |
Total GC Pause (msec) | 1,103.20 | 663.00 | 40% |
Gen0 GC (count) | 76 | 107 | -41% |
Gen1 GC (count) | 317 | 106 | 67% |
Gen2 GC (count) | 57 | 1 | 98% |
CPU / request (msec/req) | 4.17 | 2.33 | 44% |
% CPU Time spent on GC | 6.40% | 2.30% | 64% |
Test 2
In this scenario the number of requests/sec went up 70%, and less time was spent in GC.
Area | 5.2.2 | 5.2.3 | Delta % |
Total request (count) | 5,246 | 8,895 | |
Trace duration (seconds) | 30 | 30 | |
Request/second | 174.87 | 296.50 | 70% |
GC CPU Samples (msec) | 39,615 | 34,704 | 12.40% |
Allocations/Request (MB/Request) | 6.382 | 4.739 | 34.66% |
Total GC Pause (msec) | 2,974.60 | 3,215.70 | -8.11% |
Gen0 GC (count) | 76 | 99 | -30.26% |
Gen1 GC (count) | 317 | 368 | -16.09% |
Gen2 GC (count) | 57 | 45 | 21.05% |
CPU / request (msec/req) | 87.42 | 155.63 | -78.03% |
% CPU time spent on GC | 8.60% | 7.80% | 9.30% |
We hope you enjoy these performance and functionality improvements!