BinarySerializer icon indicating copy to clipboard operation
BinarySerializer copied to clipboard

Span and Memory

Open abrasat opened this issue 5 years ago • 3 comments

Would the usage of Memory<T>/Span>T> in the BinarySerializer implementation bring any advantages in terms of performance? Is there anything planned in this direction?

abrasat avatar Jul 23 '19 14:07 abrasat

I actually looked at this recently and my feeling is that for the moment it is probably not worth it for two main reasons. First, the project is currently built against .net standard 1.3. The newer memory classes aren't supported until .net standard 2.1 (currently in preview). Second, while performance is important, I think interoperability is much more important. There are other ways of serializing and storing data that will always be superior to this library as the main intent of this library is to make working with non-standards easier. That being said, I think some of the new memory support is very cool and most likely I will revisit this down the road as it spreads into all .net frameworks.

jefffhaynes avatar Jul 24 '19 14:07 jefffhaynes

https://www.nuget.org/packages/System.Memory/ I think they are supported on .NET Standard 2.0, it's just there won't be any performance gains when not running on .NET Core.

Mephistofeles avatar Aug 04 '19 11:08 Mephistofeles

Thanks, good tip. Unfortunately, without span and memory overloads in streams, I'm not sure there is a significant advantage to introducing them. If anyone has any ideas for other places where these would help in the current design I'm happy to try.

jefffhaynes avatar Aug 05 '19 03:08 jefffhaynes