Skip to content
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

.NET 10 Preview 3 - Runtime #9823

Merged
merged 4 commits into from
Apr 7, 2025
Merged

Conversation

jamesmontemagno
Copy link
Member

No description provided.

@AndyAyersMS
Copy link
Member

@amanasifkhalid are you planning on adding the codegen notes?

@amanasifkhalid
Copy link
Member

@AndyAyersMS yes, I'll have something up shortly...


For more information on stack allocation improvements in the JIT compiler, check out [dotnet/runtime #108913](https://github.com/dotnet/runtime/issues/108913).

## Improved Code Layout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndyAyersMS I'm not sure how we want to highlight this work externally. Right now, it reads pretty bookish, though I'm not sure if there's a way around that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to keep this at a higher level we could create a benchmark with similar pattern and use the [MemoryDiagnoser] to show there is now less allocation.

Though it might also run a bit slower since we're now paying to zero init the array in the method rather than getting zeroed memory "for free" from the heap. Structuring the benchmark so it properly reflects when this cost is paid on .NET 9 might be tricky.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant the 3-opt writeup.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the 3-opt writeup is ok.

}
```

The lifetime of `words` is scoped to the `Print` method, and the JIT can avoid heap-allocating the strings `"Hello"` and `"world!"` already. However, the fact that `words` is an array of `strings`, a reference type, would previously stop the JIT from stack-allocating it. Now, the JIT can eliminate every heap allocation in the above example. At the assembly level, the code for `Print` used to look like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the strings are actually heap allocated here, but that happens when the method is JITed, and their addresses are stable and can be incorporated into the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


For more information on stack allocation improvements in the JIT compiler, check out [dotnet/runtime #108913](https://github.com/dotnet/runtime/issues/108913).

## Improved Code Layout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to keep this at a higher level we could create a benchmark with similar pattern and use the [MemoryDiagnoser] to show there is now less allocation.

Though it might also run a bit slower since we're now paying to zero init the array in the method rather than getting zeroed memory "for free" from the heap. Structuring the benchmark so it properly reflects when this cost is paid on .NET 9 might be tricky.

@jamesmontemagno
Copy link
Member Author

Please ping me when ready to merge

@amanasifkhalid
Copy link
Member

@jamesmontemagno I don't have anything else to add

@jamesmontemagno
Copy link
Member Author

@AndyAyersMS anything else?

@jamesmontemagno jamesmontemagno merged commit 1290dec into dotnet10-p3 Apr 7, 2025
2 checks passed
@jamesmontemagno jamesmontemagno deleted the dotnet10-p3-runtime branch April 7, 2025 20:54
jamesmontemagno added a commit that referenced this pull request Apr 10, 2025
* stage P3

* cleanup

* efcore doc updates for preview 3

* .NET MAUI in .NET 10 Preview 3 (#9826)

* .NET MAUI in .NET 10 Preview 3

* Update .NET MAUI release notes for preview 3

* .NET 10 P3 - SDK Notes (#9822)

* SDK Start

* Add first draft of SDK features for p3

* Update release-notes/10.0/preview/preview3/sdk.md

* Update release-notes/10.0/preview/preview3/sdk.md

* Update release-notes/10.0/preview/preview3/sdk.md

Co-authored-by: Youssef Victor <[email protected]>

* Update release-notes/10.0/preview/preview3/sdk.md

Co-authored-by: Youssef Victor <[email protected]>

---------

Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: Youssef Victor <[email protected]>

* .NET 10 Preview 3 - Runtime (#9823)

* .NET 10 P3 Runtime

* Add JIT notes

* Fix indentation

* Feedback

---------

Co-authored-by: Aman Khalid (from Dev Box) <[email protected]>

* Add ASP.NET Core release notes for .NET 10 Preview 3 (#9835)

* Add ASP.NET Core release notes for .NET 10 Preview 3

* Add server-sent events

* Add declarative state persistence

* Add OpenAPI template option

* Add min API validation

* Add built-time env for Blazor WebAssembly

* Apply edits

* Apply suggestions from PR review

Co-authored-by: Wade Pickett <[email protected]>

* Update release-notes/10.0/preview/preview3/aspnetcore.md

Co-authored-by: Wade Pickett <[email protected]>

* Update release-notes/10.0/preview/preview3/aspnetcore.md

Co-authored-by: Wade Pickett <[email protected]>

* Update release-notes/10.0/preview/preview3/aspnetcore.md

Co-authored-by: Ilona Tomkowicz <[email protected]>

* Update release-notes/10.0/preview/preview3/aspnetcore.md

Co-authored-by: Ilona Tomkowicz <[email protected]>

* Update release-notes/10.0/preview/preview3/aspnetcore.md

* Update release-notes/10.0/preview/preview3/aspnetcore.md

Co-authored-by: Daniel Roth <[email protected]>

---------

Co-authored-by: Mike Kistler <[email protected]>
Co-authored-by: Wade Pickett <[email protected]>
Co-authored-by: Ilona Tomkowicz <[email protected]>
Co-authored-by: Pavel Savara <[email protected]>

* Updates for P3 (#9831)

* .NET 10 P3 - Libraries (#9824)

* .NET 10 P3 - Libraries

* Introduce an AOT-Safe Constructor for ValidationContext

* Support for Telemetry Schema URLs in ActivitySource and Meter

* Byte-Level Support in BPE Tokenizer

* ML.NET notes

* Tensor update notes

---------

Co-authored-by: Tarek Mahmoud Sayed <[email protected]>
Co-authored-by: Michael Sharp <[email protected]>

* cleanup

* cleanup

* cleanup

* cleanup

* Initial draft of P3 release notes (#9832)

* cleanup

* cleanup

* Update release-notes/10.0/preview/preview3/csharp.md

Co-authored-by: Martin Costello <[email protected]>

* Update release-notes/10.0/preview/preview3/aspnetcore.md

Co-authored-by: Mike Kistler <[email protected]>

* update code block

* Add global.json local sdk support details

* Added WPF notes (#9844)

* update readmes

* fix readme

* Updated 10.0.0-preview.3.md with content and Nuget list

* cleanup 1

* Implement feature X to enhance user experience and optimize performance

* Update release-notes/10.0/preview/preview3/10.0.0-preview.3.md

Co-authored-by: Martin Costello <[email protected]>

* Updated windowsdesktop Urls

* cleanup

* updat elinux

* udpated

* Fix table

---------

Co-authored-by: maumar <[email protected]>
Co-authored-by: David Ortinau <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: Youssef Victor <[email protected]>
Co-authored-by: Aman Khalid (from Dev Box) <[email protected]>
Co-authored-by: Daniel Roth <[email protected]>
Co-authored-by: Mike Kistler <[email protected]>
Co-authored-by: Wade Pickett <[email protected]>
Co-authored-by: Ilona Tomkowicz <[email protected]>
Co-authored-by: Pavel Savara <[email protected]>
Co-authored-by: Merrie McGaw <[email protected]>
Co-authored-by: Tarek Mahmoud Sayed <[email protected]>
Co-authored-by: Michael Sharp <[email protected]>
Co-authored-by: Kathleen Dollard <[email protected]>
Co-authored-by: Martin Costello <[email protected]>
Co-authored-by: Andy (Steve) De George <[email protected]>
Co-authored-by: victorisr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants