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

Zero copy deserialization #135

Closed
armaniferrante opened this issue Mar 30, 2021 · 4 comments
Closed

Zero copy deserialization #135

armaniferrante opened this issue Mar 30, 2021 · 4 comments

Comments

@armaniferrante
Copy link
Member

Explore adding a zero-copy deserialization feature that can be opted into instead of using borsh.

@armaniferrante
Copy link
Member Author

Not having this is the main reason I can think of that someone wouldn't use Anchor. Bumping to P1.

@armaniferrante
Copy link
Member Author

armaniferrante commented Apr 17, 2021

Addressed by #202 and #206.

@dzmitry-lahoda
Copy link

Is that zero copy based on structs references as API to state or traits? Is it borsh compatible in binary format? Does it works on non x86 cpus? how it works with growing stuctrues? and just wire this to other stuff solana-labs/solana#13391 (comment)

@armaniferrante
Copy link
Member Author

armaniferrante commented Apr 18, 2021

Zero copy here directly re-interprets the bytes from the AccountInfo's &mut [u8] as a reference to the zero-copy data structure, where all fields are POD types.

More specifically the account struct must implement pub trait ZeroCopy: Discriminator + Copy + Clone + bytemuck::Zeroable + bytemuck::Pod {}.

Growing structures aren't currently supported, and it's not necessarily borsh compatible in binary format (though some subset of things conveniently are, like arrays and structs), and there's no expectation it works on non x86 cpus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants