-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's new in .NET 8 Preview 1 #8133
Comments
NativeAOT support for macOS x64 and arm64. Thank Filip Navara for contributing it. |
NativeAOT binary size improvements, in particular on Linux. Size of native AOT compiled HelloWorld on Linux x64 improved from xxx MB in .NET 7 to yyy MB in .NET 8 Preview 1 (fill in actual numbers based on where we land after the cutoff). cc @MichalStrehovsky |
BCL: Utility methods for working with randomnessBoth System.Random and System.Security.Cryptography.RandomNumberGenerator have gained utility methods for randomly choosing items from the input set ("with replacement"), called Shuffle is useful in reducing training bias in Machine Learning (so the first thing isn't always training, and the last thing always test): YourType[] trainingData = LoadTrainingData();
Random.Shared.Shuffle(trainingData);
IDataView sourceData = mlContext.Data.LoadFromEnumerable(trainingData);
DataOperationsCatalog.TrainTestData split = mlContext.Data.TrainTestSplit(sourceData);
model = chain.Fit(split.TrainSet);
IDataView predictions = model.Transform(split.TestSet);
... Shall we play a game? How about Simon? private static ReadOnlySpan<Button> s_allButtons = new[]
{
Button.Red,
Button.Green,
Button.Blue,
Button.Yellow,
};
...
Button[] thisRound = Random.Shared.GetItems(s_allButtons, 31);
// rest of game goes here ... |
CLR AppModel team: NativeAOT size improvementsOption to publish as Native AOT was first introduced in .NET 7. In .NET 8, we're refining some of the fundamentals such as size. Publishing app with Native AOT creates a fully self-contained version of you app that doesn't need a runtime - everything is included in a single file. We worked on making this single file smaller. Linux builds are now up to 50% smaller. Here's the sizes of a Hello World app with Native AOT that includes the entire .NET runtime:
|
The removal of libstdc++ dependency is unrelated to experiments with "from scratch" Linux containers. I would avoid mentioning "from scratch" containers here. If we want to talk about "from scratch" Linux containers in preview blog posts, we need do put in place testing and documentation first. |
System.Text.Json ImprovementsWe're continuing to improve System.Text.Json, particularly with respect to performance and reliability enhancements of the source generator when used in conjunction with ASP.NET core in NativeAOT applications. Here's a list of new features that were shipped in Preview 1: Missing member handling dotnet/runtime#79945It is now possible to configure object deserialization behavior, whenever the underlying JSON payload includes properties that cannot be mapped to members of the deserialized POCO type. This can controlled by setting a JsonSerializer.Deserialize<MyPoco>("""{"Id" : 42, "AnotherId" : -1 }""");
// JsonException : The JSON property 'AnotherId' could not be mapped to any .NET member contained in type 'MyPoco'.
[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
public class MyPoco
{
public int Id { get; set; }
} Source generator support for
|
Mono: .NET Hot Reload supports adding instance fields, properties and events.NET on mobile and WebAssembly now supports adding instance fields, properties and events to existing classes when using Hot Reload. This also enables other C# and Razor language features that use instance fields under the hood, such as certain types of C# lambdas and some uses of Razor's |
WebAssembly: experimental "Webcil" a new container format for .NET assembliesIn some environments, firewalls and anti-virus tools prevent .NET WebAssembly applications from functioning correctly because .NET As a potential workaround, the Quick start guide:
Note: Webcil is not supported in Blazor WebAssembly apps in this preview. It will be enabled in a later preview If you find that your AV or firewall still flags |
CodeGenCommunity PRs (Many thanks to JIT community contributors!)
Cloud Native
Arm64Arm64 performance improvement work is ongoing as planned in Issue#77010.
AVX-512.NET 8 will support the AVX-512 ISA extensions as planned in Issue#77034.
General SIMD improvements
PGOFundamental PGO improvements are in progress as planned in Issue#74873.
Loop Optimizations
General Optimizations
JIT Throughput Improvements
|
.NET Libraries - System.Numerics and System.Runtime.IntrinsicsWe reimplemented Added the initial managed implementation of Rewrote Matrix3x2 and Matrix4x4 to better take advantage of hardware acceleration: dotnet/runtime#80091. This resulted in up to 48x perf improvements for some benchmarks. 6-10x improvements were more common. -- NOTE: Improvements to Hardware Intrinsics are now annotated with the Added the |
.NET 8 container images are using Debian 12 (Bookworm)Every two years, there is both a new Debian and .NET LTS released. Fortunately, the Debian release always ships first, often at the mid-point of the year, while .NET ships closer to the end. This is important because (A) Debian is the default Linux distro in our container images, and (B) we don't change the Debian version in those images for a major release once it is generally available. To ensure that we're preparing everyone for the transition to a new Debian release, we try to adopt it with Preview 1. We did that with .NET 6 Preview 1 and Debian 11 (Bullseye) and we're doing it again with .NET 8 and Debian 12 (Bookworm). If you pull one of our Note that Debian Bookworm includes OpenSSL 3. That doesn't matter for most users since .NET can use both OpenSSL 1.x and 3.x without issue. |
.NET 8 container images are non-root-capableContainer base images are almost always configured to run with the There is a better way. Starting with .NET 8, all container images that we publish will be non-root capable. That means you'll only need to add a one-liner at the end of your Dockerfiles or a similar instruction in your Kubernetes manifests, in order to run as non-root. This is the one-liner you'll be able to use to configure containers as non-root (for Dockerfiles): USER app You can also launch container images with In this example, root-requiring commands are blocked. The presence of the non-root As part of this change, we changed the default port from port We also added a new environment variable to make it easier to change ports: That means that you will need to adopt the following pattern to launch container .NET 8 ASP.NET Core images, even .NET 8 images are run as docker run --rm -it -p 8080:8080 aspnetapp You can change the port back to port 80 by using the environment variable, either the existing or new one: docker run --rm -it -p 8080:80 -e ASPNETCORE_HTTP_PORTS=80 aspnetapp If you change the port back to port 80, you cannot run as non-root. Those choices are mutually exclusive. We will publish a deeper-dive blog post on non-root-capable container images soon. |
.NET 8 container tagging change.NET 8 preview container images will be exposed with This change was made based on a community request. For example, to pull the .NET 8 Preview SDK, the following tag will be needed: docker run --rm -it mcr.microsoft.com/dotnet/sdk:8.0-preview As stated, we will start publishing images with the |
|
@MichalStrehovsky thanks for providing this! |
Build your own .NET from dotnet/dotnet.NET is now buildable on Linux directly from the dotnet/dotnet repository. It uses dotnet/source-build to build .NET runtimes, tools and SDKs. This is the same build that Red Hat and Canonical use to build .NET, for example. Over time, we will extend it to support macOS and Windows. See build instructions to build the VMR on your own machine. Building in a container will be the easiest approach for many people, since our We're calling this new repository a Virtual Mono Repository (VMR). It has the benefits of a true monorepo but is a regularly-updated projection of the many existing repos that contributors work in (more efficiently) ever day. We believe that the split between the VMR and the much smaller "working repos" is the future of the .NET project. We expect that cross-cutting features will be easier to build in the VMR, however, we're not quite that far along yet. We see this new approach as being a significant step forward in approachability for building .NET as a whole product from source. Prior to .NET 8, building from source was possible, but required creation of a "source tarball" from the dotnet/installer commit that corresponded to a release. This is no longer necessary. The repository will have tags corresponding to each release, as well as |
@leecow @JonDouglas @lambdageek @thaystg @lewing These three improvements listed above are for web scenarios, so I'm planning to cover them in the ASP.NET Core blog post: |
.NET 8 + Ubuntu Chiseled container imagesWe are publishing Ubuntu Chiseled images with .NET 8. This type of image is for developers that want the benefit of appliance-style computing, even more so than you get with regular containers. We expect that Ubuntu chiseled images will be supported in production by both Canonical and Microsoft by the time .NET 8 ships. We plan to ship to dotnet/monitor images exclusively as Ubuntu Chiseled, starting with .NET 8. That's notable because the monitor images are the one production app image we publish. Chiseled images have a lot of benefits:
You can see the pattern for producing chiseled images, with our aspnetapp sample. It only requires a one-line change. Chiseled images are currently published to our nightly repos, for .NET 6 and .NET 7 versions. |
Linux support and baseline targetWe are updating our minimum baselines for Linux for .NET 8. There are three notable changes.
There are no other significant changes. We will continue to support Linux on Arm32, Arm64, and x64 architectures. Note that these changes only apply to the Microsoft build. Organizations using source-build will make different choices, typically producing one build for and that only works with one distro version, like Ubuntu 24.04. The following demonstrates the Ubuntu 16.04 $ docker run --rm ubuntu:16.04 ldd --version
ldd (Ubuntu GLIBC 2.23-0ubuntu11.3) 2.23
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper. |
I originally misread that as ".NET 8 container images are not root-capable". Have you considered using different phrasing to avoid that confusion? |
Do you have a suggestion? "Non-root" and "rootless" are the two common terms. They equally apply to the Chiseled image, for example. Whatever the term is we use for that, we should use sometime very similar for these other images, like "non-root-capable" or "rootless-capable". I guess we could use ".NET 8 container images include a non-root user" as the title and then in the text explain that this makes them "non-root capable". Would that be better? Part of the issue is that this is mostly a new concept. We talked to the Chainguard folks. They are doing something similar, although their images are much more like our Chiseled ones. In terms of generic images, this approach appears to be new. As a result, there isn't really a term. I agree that between "images with a non-root user" and "non-root-capable images", that the former is simpler and easier to understand language. Either would work, however. Again, this is all new so the terminology feels strange. Thanks for pushing on this. It is helpful. |
New Performance-Focused Types in the Core LibrariesMultiple new types have been added to the core libraries to enable developers to improve the performance of their code in common scenarios. The new private static readonly FrozenDictionary<string, bool> s_configurationData =
LoadConfigurationData().ToFrozenDictionary(optimizeForReads: true);
...
if (s_configurationData.TryGetValue(key, out bool setting) && setting)
{
Process();
} The existing Another example of a new type that helps a developer to invest a bit of time upfront in exchange for much faster execution later is the new private static readonly char[] s_chars = "-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".ToCharArray();
...
int i = str.IndexOfAny(s_chars); That, however, requires either not doing any kind of vectorization to improve the efficiency of the search, or it involves taking time on each invocation of IndexOfAny to compute the necessary state to speed up the operation. Now instead, it can be written as: private static readonly IndexOfAnyValues<char> s_chars = IndexOfAnyValues.Create("-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz");
...
int i = str.AsSpan().IndexOfAny(s_chars); precomputing all of that state once such that it's available for reuse on every subsequent This pattern repeats itself again with the new static string GetMessage(int min, int max) =>
string.Format(CultureInfo.InvariantCulture, "Range from {0} to {1}", min, max); C# 6 added support for string interpolation, and then C# 10 in conjunction with .NET 6 significantly improved the efficiency of these operations, enabling the same operation to be written as: static string GetMessage(int min, int max) =>
string.Create(CultureInfo.InvariantCulture, $"Range from {min} to {max}"); but doing all of the work that can be precomputed (e.g. parsing the format string) at compile time rather than on each invocation of private static readonly CompositeFormat s_rangeMessage = CompositeFormat.Parse(LoadRangeMessageResource());
...
static string GetMessage(int min, int max) =>
string.Format(CultureInfo.InvariantCulture, s_rangeMessage, min, max); These new overloads also support generic arguments, to avoid boxing overheads associated with taking everything as .NET 8 Preview 1 also adds support for new performance-focused hashing algorithms, including the new XxHash3 and XxHash128 types that provide implementations of the fast XXH3 and XXH128 hash algorithms. |
Never mind, Jan mentioned this a month ago and I forgot that comment as well :) |
Does remote debugging into a container image work for non-root containers? |
What's new in .NET 8 Preview 1
This issue is for teams to highlight work for the community that will release in .NET 8 Preview 1
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
Optional
Below are three additional items to consider. These will help the .NET 8 blog team and the community throughout the release.
Index of .NET 8 releases
Preview 1: #8133
Preview 2: #8134
Preview 3: #8135
Preview 4: #8234
Preview 5: https://github.com/dotnet/core/issues
Preview 6: https://github.com/dotnet/core/issues
Preview 7: https://github.com/dotnet/core/issues
RC 1: https://github.com/dotnet/core/issues
RC 2: https://github.com/dotnet/core/issues
The text was updated successfully, but these errors were encountered: