Skip to content
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

Improve performance of DataReader and DataWriter #186

Open
pleonex opened this issue Jul 24, 2022 · 0 comments
Open

Improve performance of DataReader and DataWriter #186

pleonex opened this issue Jul 24, 2022 · 0 comments

Comments

@pleonex
Copy link
Member

pleonex commented Jul 24, 2022

Is your feature request related to a problem?
The performance of the binary reader and writer classes is worse than the .NET alternative BinaryReader / BinaryWriter. The reason is that it doesn't benefit from hardware acceleration features and it creates several buffers (requiring allocation).

Describe the solution you'd like
Create a performance test to compare the performance and improve by:

  • Having a re-usable byte array buffer
  • Using stackalloc and Span when possible
  • Use the class BinaryPrimitives to do the little and big endianness conversion. This class from the .NET library features hardware acceleration features.

Describe alternatives you've considered
Remove the class, but we need it as BinaryReader only supports little-endian decoding.

Additional context
These classes impact the performance of most user code.
The BinaryReader class has additional performance optimizations detecting if the Stream is MemoryStream and then accessing directly to the byte array with Spans. For now we should skip this kind of optimizations. We can consider them in the future inside DataStream.

@pleonex pleonex added this to the vNext milestone Jul 24, 2022
@pleonex pleonex modified the milestones: vNext, Future Aug 18, 2023
@pleonex pleonex removed this from the Future milestone Nov 18, 2023
@pleonex pleonex added the IO label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant