Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Mark MemoryMarshal.Cast methods for aggressive inlining #16654

Merged
merged 1 commit into from
Feb 28, 2018

Conversation

AndyAyersMS
Copy link
Member

Inlining doesn't streamline the cast logic any, but it facilitates
caller struct promotion which can substantially boost perf.

See discussion in dotnet/corefx#27485.

Inlining doesn't streamline the cast logic any, but it facilitates
caller struct promotion which can substantially boost perf.

See discussion in dotnet/corefx#27485.
@AndyAyersMS
Copy link
Member Author

@ianhays PTAL

@mikedn
Copy link

mikedn commented Feb 28, 2018

Hmm, I really should improve that cast code to avoid bloating the caller...

@ahsonkhan
Copy link
Member

but it facilitates
caller struct promotion which can substantially boost perf

What other Span APIs would this be applicable to?

@AndyAyersMS
Copy link
Member Author

Perf impact measured locally...
image

@AndyAyersMS
Copy link
Member Author

If you have a Span local or parameter and inline all methods that it is passed to, then typically that local or parameter can be promoted. If there's just one method that doesn't get inlined it will block promotion.

So in the case of Marvin.ComputeHash the data parameter can only be promoted if all the calls to Cast are inlined, even if those happen in rarely taken paths.

@jkotas jkotas merged commit 355995e into dotnet:master Feb 28, 2018
@jkotas
Copy link
Member

jkotas commented Feb 28, 2018

GetReference is small enough to be naturally inlinable. You do not have to force it.

A-And pushed a commit to A-And/coreclr that referenced this pull request Feb 28, 2018
Inlining doesn't streamline the cast logic any, but it facilitates
caller struct promotion which can substantially boost perf.

See discussion in dotnet/corefx#27485.
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.

5 participants