Skip to content

Zero copy or zero alloc optimization? #289

Answered by csnover
ileixe asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, thanks for your question! Happy to hear that you are enjoying using binrw.

binrw is not a zero-copy library and it can’t be because it operates on streams, not raw memory. If your data is already in memory and you are willing to transmute, zero-copy crates will be significantly faster at parsing. The only performance advantage binrw can ever really offer over a zero-copy library is that it generates normal Rust structs which may be optimised by the compiler for your platform, and thus may be faster when used within the rest of the application, but #[repr(C)] eliminates at least some of that capability, so don’t do that. :-)

In this situation, you may want to perform partial parsing in…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@ileixe
Comment options

@csnover
Comment options

@ileixe
Comment options

@csnover
Comment options

@ileixe
Comment options

Answer selected by ileixe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #288 on September 11, 2024 23:04.