Skip to content

Add documentation for hot/cold splitting #73029

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

Merged
merged 3 commits into from
Jul 31, 2022

Conversation

amanasifkhalid
Copy link
Member

This PR adds documentation for the current status of hot/cold splitting support in the JIT, as of my internship's conclusion.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 28, 2022
@ghost ghost assigned amanasifkhalid Jul 28, 2022
@ghost
Copy link

ghost commented Jul 28, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR adds documentation for the current status of hot/cold splitting support in the JIT, as of my internship's conclusion.

Author: amanasifkhalid
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@amanasifkhalid
Copy link
Member Author

@AndyAyersMS PTAL, thank you!


This document describes the current state of hot/cold splitting in the JIT.

Hot/Cold splitting is a PGO optimization where generated code is split into frequently-executed ("hot") and
Copy link
Member

Choose a reason for hiding this comment

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

Hot/cold splitting is not strictly Profile Guided Optimization. It is quite effective even without profile data.


## Testing the JIT Without Runtime Support

Without runtime support for hot/cold splitting in .NET Core yet, testing the JIT's existing hot/cold splitting support
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Without runtime support for hot/cold splitting in .NET Core yet, testing the JIT's existing hot/cold splitting support
Without runtime support for hot/cold splitting in .NET as of summer 2022, testing the JIT's existing hot/cold splitting support

Nit: We have retired .NET Core as the name a few years ago. We are calling the product just .NET now.

@amanasifkhalid
Copy link
Member Author

Thanks for the review @jkotas, I've added your feedback in.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Nice writeup.

I noted a few instances of passive voice. I don't expect you to go through and try and remove all (or even most) of the rest. Just pointing out that often times it's not too hard to find a more active phrasing.

Comment on lines 10 to 16
Hot/Cold splitting in the JIT was previously implemented for AOT-compiled NGEN images in .NET Framework. With hot/cold
splitting support in Crossgen2 [in progress](https://github.com/dotnet/runtimelab/tree/feature/hot-cold-splitting)
(and no existing support for splitting dynamically-generated code), the feature has gone untested in the JIT since
retiring .NET Framework -- as such, regressions have surely been introduced. Furthermore, this existing implementation
has several major limitations; functions with certain features, like exception handling or switch tables, cannot be
split yet. Finally, with ARM64/x64 performance parity being a high priority for CoreCLR, it is key hot/cold splitting
is implemented for ARM64 code generation, too.
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 somebody could get confused by the mixed use of tense here and not be entirely sure what the "current state" actually is.

Consider sectioning this part off as ## Background and describing just the before state in past tense.

Comment on lines 5 to 6
Hot/Cold splitting is an optimization where generated code is split into frequently-executed ("hot") and
rarely-executed ("cold") parts and placed in separate memory regions. Increased hot code density better leverages
Copy link
Member

Choose a reason for hiding this comment

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

Nit -- keep an eye out for passive voice and try to avoid it where you can. Here it seems pretty easy:

Suggested change
Hot/Cold splitting is an optimization where generated code is split into frequently-executed ("hot") and
rarely-executed ("cold") parts and placed in separate memory regions. Increased hot code density better leverages
Hot/Cold splitting is an optimization that splits code into frequently-executed ("hot") and
rarely-executed ("cold") parts and places the parts in separate memory regions. Increased hot code density better leverages


Hot/Cold splitting is an optimization where generated code is split into frequently-executed ("hot") and
rarely-executed ("cold") parts and placed in separate memory regions. Increased hot code density better leverages
spatial locality, which can improve application performance via fewer instruction cache misses, less OS paging, and
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
spatial locality, which can improve application performance via fewer instruction cache misses, less OS paging, and
spatial locality, improving application performance via fewer instruction cache misses, less OS paging, and

Copy link
Member

Choose a reason for hiding this comment

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

(you get the idea)

architecture-specific workarounds. However, if the JIT supports splitting functions multiple times in the future, this
may be worth revisiting.

In the absence of PGO data, the JIT assumes exceptions occur rarely to justify moving handlers to the cold section.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
In the absence of PGO data, the JIT assumes exceptions occur rarely to justify moving handlers to the cold section.
In the absence of PGO data, the JIT assumes exceptions occur rarely; this justifies moving handlers to the cold section.

@amanasifkhalid
Copy link
Member Author

@AndyAyersMS thank you for the review -- I've cleaned up some of the phrasing.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Didn't check everywhere but looks like quite a bit of the passive voice was cleaned up.

Thanks.

@AndyAyersMS AndyAyersMS merged commit 13b4bb7 into dotnet:main Jul 31, 2022
@amanasifkhalid amanasifkhalid deleted the splitting-doc branch August 1, 2022 00:08
@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants