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

Add BufReader wrapper with performance enhancements #141

Merged
merged 2 commits into from
Aug 26, 2022

Conversation

csnover
Copy link
Collaborator

@csnover csnover commented Aug 24, 2022

Do you like fast reads? Well then you’ll like this new thing probably.

@v1gnesh
Copy link

v1gnesh commented Aug 25, 2022

Could you add some examples of how to sprinkle this magic on top of a struct.
If there's a huge binary file that has known 'record' sizes, and I can set the size of that buffer to the record size.

@csnover
Copy link
Collaborator Author

csnover commented Aug 26, 2022

Could you add some examples of how to sprinkle this magic on top of a struct. If there's a huge binary file that has known 'record' sizes, and I can set the size of that buffer to the record size.

The API is nearly identical to std::io::BufReader, so you can just follow those examples. However, it would probably be a bad idea to set the buffer size to the size of a single record (unless the records are very large). If you are going to try tuning the buffer size, you’d typically want to do that based on the I/O and memory characteristics of the hardware you are planning to run on, not the content being buffered.

@@ -4,11 +4,15 @@
//! used by binrw. In no_std environments, a compatible subset API is exposed
//! instead.

#[cfg(feature = "std")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason our BufReader implementation is not available for no_std users?

Copy link
Owner

@jam1garner jam1garner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #143 for future work

@jam1garner jam1garner merged commit 5a18168 into jam1garner:master Aug 26, 2022
@v1gnesh
Copy link

v1gnesh commented Aug 26, 2022

If you are going to try tuning the buffer size, you’d typically want to do that based on the I/O and memory characteristics of the hardware you are planning to run on, not the content being buffered.

Thank you, makes sense. For my platform, that's an exercise on its own!

@csnover csnover deleted the non-lobotomised-bufreader branch August 31, 2022 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

3 participants