Closed abdullin closed 7 years ago
If you have ideas on how to achieve zero copy from native to managed memory I'm all ears on a PR, even if it's not fully fledged out. I've made several different attempts all of which resulted in no measurable performance gain. I haven't tried ArraySegment, but at first glance it takes an array in the constructor.
@CoreyKaylor thank you for the answer. It seems that the only feasible options of consuming unmanaged memory in the managed space is UnmanagedMemoryStream (need to benchmark the performance first, though).
Closing the ticket for now. Will send a PR if something works out.
I'm interested, why does ValueStructure copy bytes, creating a new allocation, instead of passing out something like an ArraySegment? Is there a reason why this option isn't supported in this library (e.g. as an Opt-in)?
I understand that this segment will be valid only during the lifetime of the transaction (that's the nature of LMDB).