Skip to content

Conversation

@armaniferrante
Copy link
Contributor

@armaniferrante armaniferrante commented Apr 15, 2021

Addresses

Provides the ability to opt into zero copy deserialization for accounts. This means, instead of using borsh, accounts are defined with "plain old data" types that map 1-1 to the bytes in the backing AccountInfo's &mut [u8].

Other than being more efficient, the most salient benefit this provides is the ability to define account types larger than the max stack or heap size. This is used in special cases, for example, the Serum DEX event queue. When using borsh, one is limited, since the account has to be copied and deserialized into a new data structure. With zero copy deserialization, everything is, effectively, lazy loaded on field access.

To use this feature, one must define their account as

#[account(zero_copy)]
pub struct MyAccount {...}

Or for associated accounts

#[associated(zero_copy)]
pub struct MyAccount {...}

Otherwise, Borsh is still used, by default. The ts client will still work as expected in either case.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants