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

Allow inline relocations in dehydrated data #78545

Merged
merged 2 commits into from
Nov 20, 2022

Conversation

MichalStrehovsky
Copy link
Member

This is a follow up to #77884. In the original pull request, all relocation targets went into a lookup table. This is not very efficient to represent rarely used relocs. In this update, I'm extending the dehydration format to allow representing relocations inline - instead of indirecting through the lookup table, the target immediately follows the instruction. I'm changing the emitter to emit this if there's less than 3 references to the reloc.

This produces a ~0.5% size saving. It likely also speeds up the decoding at runtime since there's less cache thrashing. On a hello world, the lookup table originally had about 11k entries. With this change, the lookup table only has 1700 entries.

Cc @dotnet/ilc-contrib

This is a follow up to dotnet#77884. In the original pull request, all relocation targets went into a lookup table. This is not a very efficient to represent rarely used relocs. In this update, I'm extending the dehydration format to allow representing relocations inline - instead of indirecting through the lookup table, the target immediately follows the instruction. I'm changing the emitter to emit this if there's less than 2 references to the reloc.

This produces a ~0.5% size saving. It likely also speeds up the decoding at runtime since there's less cache thrashing. On a hello world, the lookup table originally had about 11k entries. With this change, the lookup table only has 1700 entries.
@ghost
Copy link

ghost commented Nov 18, 2022

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

Issue Details

This is a follow up to #77884. In the original pull request, all relocation targets went into a lookup table. This is not very efficient to represent rarely used relocs. In this update, I'm extending the dehydration format to allow representing relocations inline - instead of indirecting through the lookup table, the target immediately follows the instruction. I'm changing the emitter to emit this if there's less than 3 references to the reloc.

This produces a ~0.5% size saving. It likely also speeds up the decoding at runtime since there's less cache thrashing. On a hello world, the lookup table originally had about 11k entries. With this change, the lookup table only has 1700 entries.

Cc @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: MichalStrehovsky
Labels:

area-NativeAOT-coreclr

Milestone: -

If multiple relocations follow after each other, generate a single command with the payload specifying the number of subsequent relocations. This saves additional 0.1%.
@MichalStrehovsky
Copy link
Member Author

A pushed out one more commit to generate runs of inline relocations. This allows us to skip emitting the command byte if multiple inline relocations follow each other. Saves additional 0.1%.

The total diff is still pretty small but I'd recommend reviewing commit by commit so that there's less to review.

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

LGTM!

@MichalStrehovsky MichalStrehovsky merged commit ce3e9fc into dotnet:main Nov 20, 2022
@MichalStrehovsky MichalStrehovsky deleted the inlinereloc branch November 20, 2022 23:32
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants