-
Notifications
You must be signed in to change notification settings - Fork 344
Implement Memory<T> final design #1298
Comments
|
I think? the pinnable ref on span removes the need for these? |
@benaadams, I think it covers TryGetPointer. TryGetArray might be needed for interop with existing APIs that operate on arrays only. But then, I am not sure we want to ship such leaky abstraction. |
It is necessary for efficient interop. It is pretty common for efficient interop to be leaky. And if you do not provide the official way to do it, people have to resort to hacks to do it. The purist view won for |
Make sure that includes measuring in Kestrel as well.
Yes, lets keep both.
I'm not sure we ever needed Reserve really... |
@davidfowl, I thought I added Reserve because you needed it. |
@KrzysztofCwalina yea, but it's not required anymore. Pipelines manually ref counts by directly using |
So I can definitely see reasons for TryGetArray, some libraries require ArraySegments. But TryGetPointer is now only used in two places in the code base, and both of those were where @pdeligia and I couldn't work out the lifetime of the native pointer. Both are inside TcpConnections.
They both only work with OwnedMemory that has been pinned. So again this kind of breaks abstraction of |
Any voluntairs to fix the files linked above to not use TryGetPointer? |
@KrzysztofCwalina If it's not urgent and you don't mind a bit of possible mentoring in the PR I can work on this today. EDIT: Actually that looks quite subtle, so someone with more context would probably handle it better. I see what you mean @mjp41 about not being able to work out the lifetime of the pointer since it's passed off to |
@KodrAus, thanks for the offer though! We would be more than happy to help you get started if you wanted to start contributing in this area. But if you feel this issue is "too subtle", maybe a different issue would be a better fit. |
@KrzysztofCwalina Good to know! Well I'm still interested in this issue, so might take it over to gitter to work out specifics. Code-wise I suspect it's fairly simple, but since I've just started actually using the new memory bits I need to get up to speed. |
I was worried about extra overhead of the struct when you just need the pointer for already pinned cases but maybe that's fine... |
The other problem is that sometimes things have to be pinned long term (like for RIO) and the pointer for the backing memory just needs to be available but not constantly pinned and freed. |
I am not sure how to express this (which memory is which; pinned or not) in the type system |
Agreed, but this is why I like |
Seems like all the items are done. |
This probably needs to be broken down into additional issues/specific work items.
The text was updated successfully, but these errors were encountered: