Skip to content

JIT: Let cold blocks participate in layout opts [experiment]#129315

Closed
BoyBaykiller wants to merge 2 commits into
dotnet:mainfrom
BoyBaykiller:layout-opt-cold-blocks
Closed

JIT: Let cold blocks participate in layout opts [experiment]#129315
BoyBaykiller wants to merge 2 commits into
dotnet:mainfrom
BoyBaykiller:layout-opt-cold-blocks

Conversation

@BoyBaykiller

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 12, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 12, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@jakobbotsch

Copy link
Copy Markdown
Member

The diffs show more or less what I would expect -- size improvements at the cost of moving 0 weight blocks inline and polluting the icache. It seems unlikely to be a good change.

@AndyAyersMS

Copy link
Copy Markdown
Member

Copying what I wrote over on the discord...

There is an argument to be made that letting a little bit of cold code into the hot section could be good, if it actually makes the hot section more compact. EG a long branch around a simple one instruction cold block. But we don't have accurate metrics for what the JIT considers the hot and cold sections today: we put all the code into the hot section (no splitting). It might be worth introducing a metric for unsplit codegen to see if the "true" hot section is getting smaller or what we're mostly seeing is the cold section getting smaller.

I don't think this effect is easy to model with our current layout approach since we don't know the sizes of things or how span-dependent branch encodings work when we do the layouts. I know @amanasifkhalid and I discussed trying to model this but never did because we couldn't quite get a handle on it.

The long-range plan here is to move away from having so many blocks with zero profile weight. We allow a small amount of residual (probably synthetic) profile to wash over all blocks, and then the cold section possibly gets plausible layout, but we still would miss the opportunistic cold-in-hot cases without some kind of modelling.

Also someday, actual splitting... I think we had a plausible approach lined up where we put the cold code section at the far end of the code heap (odd things happen if the cold code can end up at a lower address). Perhaps worth dusting this off. I think we still stress test this setup, so maybe not even bit rotted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants