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

Conversation

@benaadams
Copy link
Member

@benaadams benaadams commented Oct 27, 2018

Store the shared ArrayMemoryPool in a field of its derived sealed type so the Jit can "see" the exact type when the MemoryPool<T>.Shared property is inlined which will allow it to devirtualize calls made on it.

Is a Roslyn proposal dotnet/roslyn#30797 by @stephentoub where field initalizer, backing field and property could be combined via { get } = to support devirtualization by having the auto-backing field be created as the derived type rather than the exposed type.

Similar scenario to ArrayPool<T>.Shared dotnet/coreclr#20637

@AndyAyersMS

var mem = MemoryPool<byte>.Shared.Rent();

might be a double devirt inline "opportunity" as MemoryPool<T>.Shared.Rent is

MemoryPool<T>.Shared.Rent
=> ArrayMemoryPool<T>.Rent
=> new ArrayMemoryPoolBuffer
=> ArrayPool<T>.Shared.Rent
=> TlsOverPerCoreLockedStacksArrayPool<T>.Rent

/cc @ahsonkhan @jaredpar

@stephentoub stephentoub merged commit c5cad0c into dotnet:master Oct 27, 2018
@benaadams benaadams deleted the memory-pool-devirt branch October 27, 2018 05:27
@karelz karelz added this to the 3.0 milestone Nov 15, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants