-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
New pooled memory types #6821
New pooled memory types #6821
Conversation
There are other custom pool implementations that we currently have, like https://github.com/Ryujinx/Ryujinx/blob/master/src/Ryujinx.Graphics.Vic/Image/BufferPool.cs |
They could be replaced, but I think it'd be wise to study them for possible behavior/perf differences. If any of them wrap ArrayPool, those could be drop-in replaced by these new ones without much concern. But any that have a custom algorithm (like |
I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, sorry for the late review!
This PR adds 2 new types for using pooled memory:
MemoryOwner<T>
is a generic class for easy access to pooled memory.SpanOwner<T>
is generic value type (readonly ref struct
) that serves the same purpose in more constrained scopes, without requiring an additional allocation to manage it.Both are intended for future optimization and to eventually replace the existing
ByteMemoryPool
andByteMemoryPool.ByteMemoryPoolBuffer
types inRyujinx.Common.Memory
, which have the following limitations:byte
buffersIMemoryOwner<byte>
implementation (the nestedByteMemoryPoolBuffer
class) is private and returned as the interface. Usage as the concrete type would be faster.ByteMemoryPoolBuffer
instance.This PR also uses the
SpanOwner
type to target a memory profiler hotspot, replacing a new array allocation with pooled memory inRyujinx.Graphics.Vulkan.MultiFenceHolder
. The table below shows the measured # of newFenceHolder[]
allocations per second of gameplay (actual gameplay, past the title/intro/loading etc.).Before this PR (a.k.a., # of Allocations Eliminated by this PR)