Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News ASP.NET Core 8 Preview 2: QuickGrid and Enhanced Blazor WebAssembly Performance

ASP.NET Core 8 Preview 2: QuickGrid and Enhanced Blazor WebAssembly Performance

Recently, Microsoft released .NET 8 Preview 2, which is a quick follow-up to the larger Preview 1 release. With the promise of monthly releases, developers can look forward to an array of additional features in the coming months.

Preview 2 brings several enhancements to the ASP.NET Core. The highlights of the release are the Blazor QuickGrid component, which promises to simplify data presentation and manipulation, and improved performance for Blazor WebAssembly through the use of the new runtime feature called jiterpreter.

Other notable additions include a new analyzer to detect multiple FromBody attributes, new APIs in ProblemDetails for more robust integrations, and a new IResettable interface in ObjectPool the named pipes transport has also received performance improvements.

To upgrade an existing ASP.NET Core app, developers must first update the target framework of their app to net8.0. Next, they must update all package references for Microsoft.AspNetCore.* and Microsoft.Extensions.* to 8.0.0-preview.2.* version. To ensure a smooth transition, developers are also advised to review the full list of breaking changes in ASP.NET Core for .NET 8.

QuickGrid is a high-performance grid component that enables developers to display data in a tabular format with advanced features such as sorting, filtering, paging, and virtualization. To start with it, the reference to Microsoft.AspNetCore.Components.QuickGrid package is needed. The component was previously an experimental package under .NET 7 and has undergone API changes and improvements for the .NET 8 version.

To update a Blazor app that uses QuickGrid to .NET 8, developers must do some changes like renaming the Value attribute to State and the IsDefaultSort attribute to InitialSortDirection and adding IsDefaultSortColumn=true. Also, built-in support for resizable columns was eliminated, so the ResizableColumns attribute should be removed from QuickGrid.

A new runtime feature named jiterpreter boosts runtime performance in Blazor WebAssembly apps by enabling partial JIT support in the .NET IL interpreter. AOT compilation can improve performance but comes with the downside of a larger download size and incompatibility issues. Now, with the jiterpreter, Blazor WebAssembly apps can achieve improved performance without the need for AOT compilation and this is automatically enabled in .NET 8 Preview 2 for Blazor WebAssembly apps.

As reported by Daniel Roth, principal program manager, ASP.NET

The jiterpreter optimizes execution of interpreter bytecodes by replacing them with tiny blobs of WebAssembly code. By leveraging the interpreter as a baseline, we’re able to optimize the most important parts of the app without having to handle more complex or obscure cases and without overly complicating the runtime. While the jiterpreter isn’t a full JIT implementation, it significantly improves runtime performance without the size and build time overhead of AOT. The jiterpreter helps when using AOT too by optimizing cases where the runtime has to fallback to the interpreter.

Also, in addition to the analyzers that were added in the previous Preview 1 version, this new analyzer will bring up a warning when attempting to resolve more than one parameter from the body in a minimal API.

(analyzer warning - image source: Microsoft)

.NET 8 Preview 2 adds IResettable to Microsoft.Extensions.ObjectPool library. The library is designed to help apps optimize memory usage by pooling expensive-to-allocate objects. The new interface simplifies the process of resetting reusable types back to their default state between uses, ensuring optimal performance.

The original .NET blog post from Microsoft also states that named pipes transport for Kestrel in .NET has received significant performance improvements in Preview 2. The enhancements include parallel connections and the reuse of NamedPipeServerStream instances, leading to a dramatic decrease in the time required to create 100,000 connections - from 5.916 seconds to just 2.374 seconds.

Regarding Blazor United, in the comments section of the release post, Roth mentioned:

Parts of Blazor United will start to land in .NET 8 Preview 3 and then addition pieces will come in with later previews. The first step is to land server-side rendering for Blazor components, which we do expect to land with Preview 3. Streaming rendering, progressive enhancement, and the integration with client rendering will happen in later previews.

Lastly, developers who are looking to use ASP.NET Core with .NET 8 Preview 2 must first install the .NET 8 SDK. However, Windows users of Visual Studio are encouraged to download the latest Visual Studio 2022 preview to make the most out of the platform. It is important to note that Visual Studio for Mac support for .NET 8 previews is currently not available.

About the Author

Rate this Article