You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is for teams to highlight work for the community that will release in .NET 8 Preview 5
To add content, use a new conversation entry. The entry should include the team name and feature title as the first line shown in the template below.
Required
## Team Name: Feature title
[link to the tracking issue or epic item for the work]
Tell the story of the feature and anything the community should pay particular attention
to be successful in using the feature.
Optional
Below are three additional items to consider. These will help the .NET 8 blog team and the community throughout the release.
Link to documentation.
Where can we send people to learn more about the feature?
Link to where you'd like people to provide feedback for this feature.
Where can people best comment on the direction of this feature?
Whether you would like assistance from the .NET 8 writers to craft a story for this feature.
// * Warnings *
MultimodalDistribution
CompilationBenchmak.BuildCompiler: Runtime=.NET 8.0, Server=True -> It seems that the distribution is bimodal (mValue = 3.44)
Introducing supplementary metrics APIs to cater to new use cases:
DI Friendly metrics APIs
Introducing the IMeterFactory interface that can be registered in DI containers and utilized to create Meter objects in an isolated manner.
// services is the DI IServiceCollection // Register the IMeterFactory to the DI container using the default meter factory implementation. services.AddMetrics();
Consumers now have the ability to obtain the meter factory and utilize it for creating a new Meter object.
Enabling the creation of Meters and Instruments with Tags
Introducing the capability to attach key-value pair tags to Meters and Instruments during their creation. This feature allows aggregators of published metric measurements to utilize the tags to differentiate the aggregated values based on these tags.
MeterOptionsoptions=newMeterOptions("name"){Version="version",// Attach these tags to the created meterTags=newTagList(){{"MeterKey1","MeterValue1"},{"MeterKey2","MeterValue2"}}};Metermeter=meterFactory.Create(options);Instrumentinstrument=meter.CreateCounter<int>("counter",null,null,newTagList(){{"counterKey1","counterValue1"}});instrument.Add(1);
The .NET SDK now includes SourceLink to help power-up the IDE experience when inspecting Sourcelinked NuGet Packages. The goal is that by bundling SourceLink into the SDK, instead of requiring a separate PackageReference for the package, more packages will include this information by default, resulting in better IDE experiences for developers all-up.
Source Link is a language- and source-control agnostic system for providing first-class source debugging experiences for binaries. The goal of the project is to enable anyone building NuGet libraries to provide source debugging for their users with almost no effort. Microsoft libraries, such as .NET Core and Roslyn have enabled Source Link. Source Link is supported by Microsoft.
Visual Studio, and many other editors, support reading Source Link information from symbols while debugging. Editors can download and display the appropriate commit-specific source for users, such as from raw.githubusercontent, enabling breakpoints and all other sources debugging experience on arbitrary NuGet dependencies.
The shipped implementation of SourceLink includes providers for git, GitHub, GitLab, Azure Repositories, and BitBucket, but there are a other providers available on NuGet. You can find more information about SourceLink at the Learn docs, and read more about the available settings the repo documentation.
Reacted by OmariO, Oxy, Damian Romanowski, CountNeuroman, Patrick Kranz and Meai
Dynamic PGO is now enabled by default. Special configuration settings are no longer needed. We anticipate performance for a broad class of applications will improve by anywhere from 5% to 500% (with 15% a reasonable expectation), depending upon the nature of application bottlenecks. In our local benchmark suite of approximately 4600 tests, 23% improved by 20% or more.
Customer experience with PGO in past releases has been uniformly positive.
Linux distribution-built (source-build) SDK now has the capability to build self-contained applications utilizing the source-build runtime packages. Distribution specific runtime package will be bundled with the source-build SDK. During self-contained deployment, this bundled runtime package will be referenced and thereby enabling the feature for the user. Please note that there are no changes for the MS-built SDK.
Thanks to our Red Hat partners, especially @tmds, for the valuable contribution to enable this feature.
SDK: Runtime-specific apps no longer self-contained by default
Since .NET 6, specifying a runtime during publish has resulted in the following warning:
warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used.
For .NET 8, we're finally taking the step of making this change. Going forward, for apps targeting net8.0 and higher Target Frameworks, -r/--runtime will no longer imply --self-contained. If you intended that behavior you'll either need to
add the CLI option explicitly, or
add the <SelfContained>true</SelfContained> property to your project files
Apps targeting net7.0 or lower remain unaffected. You can read more about this change in the breaking change notice we've posted.
We're making this change because we believe that targeting a specific platforms is an independent decision from bundling the runtime for that platform. Defaulting more apps to framework-dependent deployments means that the runtime the app runs on can be safely updated without requiring a rebuild or redeployment. It also results in smaller app sizes than self-contained deployments.
Introducing a new flavor of ASP.NET Docker Images: The Composites.
What are the composite images?
As part of the containerization performance efforts, we are now offering a new ASP.NET Alpine-based Docker image with a composite version of the runtime in Preview 5. This composite is built by compiling multiple MSIL assemblies into a single R2R output binary. Due to having these assemblies embedded into a single image, we save jitting time and thus boosting the startup performance of apps. The other big advantage of the composite over the regular ASP.NET image is that the composites have a smaller size on disk. However, all these benefits don't come without a caveat. Since composites have multiple assemblies embedded into one, they have tighter version coupling. This means the final app run cannot use custom versions of framework and/or ASP.NET binaries embedded into the composite one.
Where can we get the composite images?
As of now, the composite images are available as preview in under the mcr.microsoft.com/dotnet/nightly/aspnet repo. The tags are listed with the -composite suffix in the official nightly Dotnet Docker page.
Future Work
Right now, the composites are only based on Alpine. Based on feedback as they start getting a more widespread adoption, we have plans to enable them for distroless images, and longer term bigger distros like Ubuntu and Debian.
Community PRs (Many thanks to JIT community contributors!)
@SingleAccretion contributed 18 PRs in Preview 5. Much of this work was focused on internal JIT cleanup with the eventual goal of greatly simplifying the internal representation (IR), in particular around the representation of assignments/stores.
PR#85180 marked the start of this work and in a future preview it will result in the JIT being several percent faster when compiling user functions.
@yesmey enabled unrolling StringBuilder.Append for const string that unblocks more AVX-512 usages. It imporved the execution time of System.Tests.Perf_Enum benchmarks up to 8 % and StringBuilder up to 16%, PR#85894.
@MichalPetryka submitted PR#85398 that improved the JIT’s ability to reason about single-defined variables early-on, and PR#85349 that improved the JIT’s codegen for calls to function pointers without arguments.
AVX-512
PR#85389 enabled AVX-512 for block unrollings, which increases ranges where it previously used to fallback to memcpy/memset and reduced the execution time by half.
Various integer intrinsics are enabled for AVX512F, AVX512BW and AVX512CD, PR#85833.
NativeAOT: Optimized ThreadStatic field access for GC-type
In preview 4, with PR#82973, we optimized the field accesses that are marked as ThreadStaticLocal for primitive types. With This PR#85619, we started optimizing the GC fields as well. This gave us some really good improvements in various microbenchmarks (133 on windows/arm64, 23 on windows/x64, 16, 13, 11 improvements).
Arm64
In preview 5, we enabled a few peephole optimizations:
With PR#85032 , we enabled peephole optimization to replace str pair with stp.
With PR#85657, we enabled peephole optimization of replacing pair of ldr/str with ldp/stp inside prolog.
General optimizations
x64 instructions such as movzx, movsx and movsxd have been optimized in PR#85780, which slightly improved code-gen by eliminating more redundant mov instructions.
PR#86318 improved constant folding for some frozen objects (non-GC objects). It reduced the size of the generated code by almost 10 times (e.g., 424 bytes to 41 byte).
Runtime host determines RID-specific assets without RID graph by default
When running an application with RID-specific assets, the host determines which assets are relevant for the platform on which it's running. This applies to both the application itself and the resolution logic used by AssemblyDependencyResolver. By default in .NET 8, this determination will no longer use the RID graph, but will rely on a known list of RIDs based on how the runtime itself was built.
The RID graph has proven to be costly to maintain, difficult to understand, and generally fragile. This change is part of a longer-term goal to simplify our RID model.
Starting from .NET 8 preview 1, we have added several analyzers and code fixers that help developers verify correct and/or more performant usage of .NET Library APIs. We are thrilled to mention that most of these analyzers have been implemented by our community members. We would like to extend a big thank you to all our contributors for their hard work and dedication.
CA1856 fires when the ConstantExpected attribute not applied correctly on the parameter. CA1857 fires when a parameter annotated with the ConstantExpected attribute but the argument provided is not a constant, a constants should be used for optimal performance.
It's more efficient and clearer to call String.StartsWith than to call String.IndexOf and compare the result with zero to determine whether a string starts with a given prefix.
This rule recommends upgrading the type of specific local variables, fields, properties, method parameters, and method return types from interface or abstract types to concrete types when possible. Using concrete types leads to higher quality generated code by minimizing virtual or interface dispatch overhead and enabling inlining.
It's more efficient and clearer to use Length, Count, or IsEmpty than to call Enumerable.Any extenion method to determine whether a collection type has any elements
Constant arrays passed as arguments are not reused when called repeatedly, which implies a new array is created each time. If the passed array is not mutated within the called method, consider extracting it to a static readonly field to improve performance.
Enumerable.Cast<T> and Enumerable.OfType<T> require compatible types to function expectedly. Enumerable.Cast<T> will throw InvalidCastException at runtime for elements of incompatible types. Enumerable.OfType<T> will never succeed with elements of incompatible types, resulting in an empty sequence. Widening and user defined conversions are not supported with generic types.
Throw helpers are simpler and more efficient than an if block constructing a new exception instance. With this analyzer four analyzers added for: ArgumentNullException, ArgumentException, ArgumentOutOfRangeException and ObjectDisposedException throw helpers
Maintainability
Info
CA1510, CA1511, CA1512, CA1513
We plan to continue adding more analyzers to .NET 8 to help developers write better code and we are hoping for even more community contributions. This is a great opportunity for the community to add a new complete feature to .NET 8 SDK.
Improve your productivity in VS Code with the C# Dev Kit extension!
The C# Dev Kit extension in VS Code is now available for public preview in VS Code! Designed to improve your C# productivity in VS Code, C# Dev Kit helps you manage your code with a solution explorer, write code faster with AI-assisted suggestions and completions, and gives you new capabilities to run and debug tests in the Test Explorer. Using a Roslyn-powered language service, C# Dev Kit also greatly improves performance of C# language features such as code navigation, refactoring, IntelliSense, and more.
Linux distribution-built (source-build) SDK now has the capability to build self-contained applications utilizing the source-build runtime packages.
I don't think this feature landed in Preview 5 itself. It was implemented during Preview 5 period, and it appears to be a part of the nightly Preview 6 builds, but I can't see it in Preview 5.
Preview 5:
$ ls -1 packs/
Microsoft.AspNetCore.App.Ref
Microsoft.NETCore.App.Host.fedora.38-x64
Microsoft.NETCore.App.Ref
NETStandard.Library.Ref
Activity
WeihanLi commentedon May 18, 2023
@leecow the preview 6 link is incorrect, should be #8437
The same problem exists in preview 6/7 and rc1/2 issues
mairaw commentedon May 18, 2023
Good catch @WeihanLi. I've fixed those.
JonDouglas commentedon May 31, 2023
.NET Framework -> .NET 7 -> .NET 8 Benchmarks
// * Warnings *
MultimodalDistribution
CompilationBenchmak.BuildCompiler: Runtime=.NET 8.0, Server=True -> It seems that the distribution is bimodal (mValue = 3.44)
Simplified
Source: https://gist.github.com/jaredpar/f2fd4c87917ed0de73981a5ea410015e
tarekgh commentedon Jun 5, 2023
Enhancements to Metrics APIs
Introducing supplementary metrics APIs to cater to new use cases:
DI Friendly metrics APIs
Introducing the IMeterFactory interface that can be registered in DI containers and utilized to create Meter objects in an isolated manner.
Consumers now have the ability to obtain the meter factory and utilize it for creating a new Meter object.
Enabling the creation of Meters and Instruments with Tags
Introducing the capability to attach key-value pair tags to Meters and Instruments during their creation. This feature allows aggregators of published metric measurements to utilize the tags to differentiate the aggregated values based on these tags.
References
dotnet/runtime#77514 (comment)
dotnet/runtime#84321
dotnet/runtime#86740
Please note that the newly exposed APIs are currently undergoing refinements, which may lead to minor changes in their current exposed form.
baronfel commentedon Jun 6, 2023
SDK: SourceLink is part of the .NET SDK!
The PR is dotnet/sdk#31632
The .NET SDK now includes SourceLink to help power-up the IDE experience when inspecting Sourcelinked NuGet Packages. The goal is that by bundling SourceLink into the SDK, instead of requiring a separate PackageReference for the package, more packages will include this information by default, resulting in better IDE experiences for developers all-up.
Source Link is a language- and source-control agnostic system for providing first-class source debugging experiences for binaries. The goal of the project is to enable anyone building NuGet libraries to provide source debugging for their users with almost no effort. Microsoft libraries, such as .NET Core and Roslyn have enabled Source Link. Source Link is supported by Microsoft.
Visual Studio, and many other editors, support reading Source Link information from symbols while debugging. Editors can download and display the appropriate commit-specific source for users, such as from raw.githubusercontent, enabling breakpoints and all other sources debugging experience on arbitrary NuGet dependencies.
The shipped implementation of SourceLink includes providers for git, GitHub, GitLab, Azure Repositories, and BitBucket, but there are a other providers available on NuGet. You can find more information about SourceLink at the Learn docs, and read more about the available settings the repo documentation.
AndyAyersMS commentedon Jun 8, 2023
Codegen
@JonDouglas @JeremyLikness feel free to craft away....
Dynamic PGO is now enabled by default. Special configuration settings are no longer needed. We anticipate performance for a broad class of applications will improve by anywhere from 5% to 500% (with 15% a reasonable expectation), depending upon the nature of application bottlenecks. In our local benchmark suite of approximately 4600 tests, 23% improved by 20% or more.
Customer experience with PGO in past releases has been uniformly positive.
If you are new to Dynamic PGO we look forward to hearing about your experiences as well (good or bad).
If necessary, you can opt out of Dynamic PGO via
in your
.csprojor via similar settings in the runtime config or environment.ashnaga commentedon Jun 8, 2023
Linux distribution-built (source-build) SDK now has the capability to build self-contained applications utilizing the source-build runtime packages. Distribution specific runtime package will be bundled with the source-build SDK. During self-contained deployment, this bundled runtime package will be referenced and thereby enabling the feature for the user. Please note that there are no changes for the MS-built SDK.
Thanks to our Red Hat partners, especially @tmds, for the valuable contribution to enable this feature.
baronfel commentedon Jun 8, 2023
SDK: Runtime-specific apps no longer self-contained by default
Since .NET 6, specifying a runtime during publish has resulted in the following warning:
For .NET 8, we're finally taking the step of making this change. Going forward, for apps targeting
net8.0and higher Target Frameworks,-r/--runtimewill no longer imply--self-contained. If you intended that behavior you'll either need to<SelfContained>true</SelfContained>property to your project filesApps targeting
net7.0or lower remain unaffected. You can read more about this change in the breaking change notice we've posted.We're making this change because we believe that targeting a specific platforms is an independent decision from bundling the runtime for that platform. Defaulting more apps to framework-dependent deployments means that the runtime the app runs on can be safely updated without requiring a rebuild or redeployment. It also results in smaller app sizes than self-contained deployments.
ivdiazsa commentedon Jun 9, 2023
Alpine ASP.NET Docker Composite Images
Introducing a new flavor of ASP.NET Docker Images: The Composites.
What are the composite images?
As part of the containerization performance efforts, we are now offering a new ASP.NET Alpine-based Docker image with a composite version of the runtime in Preview 5. This composite is built by compiling multiple MSIL assemblies into a single R2R output binary. Due to having these assemblies embedded into a single image, we save jitting time and thus boosting the startup performance of apps. The other big advantage of the composite over the regular ASP.NET image is that the composites have a smaller size on disk. However, all these benefits don't come without a caveat. Since composites have multiple assemblies embedded into one, they have tighter version coupling. This means the final app run cannot use custom versions of framework and/or ASP.NET binaries embedded into the composite one.
Where can we get the composite images?
As of now, the composite images are available as preview in under the
mcr.microsoft.com/dotnet/nightly/aspnetrepo. The tags are listed with the-compositesuffix in the official nightly Dotnet Docker page.Future Work
Right now, the composites are only based on Alpine. Based on feedback as they start getting a more widespread adoption, we have plans to enable them for distroless images, and longer term bigger distros like Ubuntu and Debian.
JulieLeeMSFT commentedon Jun 9, 2023
CodeGen
Community PRs (Many thanks to JIT community contributors!)
AVX-512
NativeAOT: Optimized ThreadStatic field access for GC-type
In preview 4, with PR#82973, we optimized the field accesses that are marked as
ThreadStaticLocalfor primitive types. With This PR#85619, we started optimizing the GC fields as well. This gave us some really good improvements in various microbenchmarks (133 on windows/arm64, 23 on windows/x64, 16, 13, 11 improvements).Arm64
In preview 5, we enabled a few peephole optimizations:
strpair withstp.ldr/strwithldp/stpinside prolog.General optimizations
movzx,movsxandmovsxdhave been optimized in PR#85780, which slightly improved code-gen by eliminating more redundantmovinstructions.elinor-fung commentedon Jun 9, 2023
Runtime host determines RID-specific assets without RID graph by default
When running an application with RID-specific assets, the host determines which assets are relevant for the platform on which it's running. This applies to both the application itself and the resolution logic used by AssemblyDependencyResolver. By default in .NET 8, this determination will no longer use the RID graph, but will rely on a known list of RIDs based on how the runtime itself was built.
The RID graph has proven to be costly to maintain, difficult to understand, and generally fragile. This change is part of a longer-term goal to simplify our RID model.
You can read more about this change in the breaking change notice.
buyaa-n commentedon Jun 11, 2023
.NET Libraries analyzers
Starting from .NET 8 preview 1, we have added several analyzers and code fixers that help developers verify correct and/or more performant usage of .NET Library APIs. We are thrilled to mention that most of these analyzers have been implemented by our community members. We would like to extend a big thank you to all our contributors for their hard work and dedication.
ConstantExpectedattribute not applied correctly on the parameter. CA1857 fires when a parameter annotated with theConstantExpectedattribute but the argument provided is not a constant, a constants should be used for optimal performance.String.StartsWiththan to callString.IndexOfand compare the result with zero to determine whether a string starts with a given prefix.Enumerable.Anyextenion method to determine whether a collection type has any elementsEnumerable.Cast<T>andEnumerable.OfType<T>require compatible types to function expectedly.Enumerable.Cast<T>will throwInvalidCastExceptionat runtime for elements of incompatible types.Enumerable.OfType<T>will never succeed with elements of incompatible types, resulting in an empty sequence. Widening and user defined conversions are not supported with generic types.ArgumentNullException,ArgumentException,ArgumentOutOfRangeExceptionandObjectDisposedExceptionthrow helpersWe plan to continue adding more analyzers to .NET 8 to help developers write better code and we are hoping for even more community contributions. This is a great opportunity for the community to add a new complete feature to .NET 8 SDK.
If you are interested in contributing, please check out our list of analyzers that are ready for development and marked
up for grabs.leslierichardson95 commentedon Jun 12, 2023
Improve your productivity in VS Code with the C# Dev Kit extension!
The C# Dev Kit extension in VS Code is now available for public preview in VS Code! Designed to improve your C# productivity in VS Code, C# Dev Kit helps you manage your code with a solution explorer, write code faster with AI-assisted suggestions and completions, and gives you new capabilities to run and debug tests in the Test Explorer. Using a Roslyn-powered language service, C# Dev Kit also greatly improves performance of C# language features such as code navigation, refactoring, IntelliSense, and more.
To get started with C# Dev Kit, check out our recent announcement blog post.
omajid commentedon Jun 20, 2023
I don't think this feature landed in Preview 5 itself. It was implemented during Preview 5 period, and it appears to be a part of the nightly Preview 6 builds, but I can't see it in Preview 5.
Preview 5:
Preview 6 (nightly):
JonDouglas commentedon Jun 27, 2023
Complete via https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-preview-5/