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

New program: serialization library study #3161

Closed
joncinque opened this issue May 12, 2022 · 2 comments
Closed

New program: serialization library study #3161

joncinque opened this issue May 12, 2022 · 2 comments
Labels
stale [bot only] Added to stale content; will be closed soon

Comments

@joncinque
Copy link
Contributor

Problem

There's mostly anecdotal data about the tradeoffs of different serialization techniques used by on-chain programs. The typically used ones are:

  • Pack by hand, as in token
  • unsafe pointer casts
  • Borsh, as in governance and stake-pool, among others
  • bytemuck, as in certain token-2022 extensions
  • bincode, not used in BPF programs, but builtin programs in the monorepo use it, such as stake
  • protobuf, a bit more overhead
  • any others?

Solution

Add in a new libraries/serialization style program that compares these different approaches. #3064 was the most bare-bones prototype possible that can be used for inspiration. Some features to compare them on would be:

  • compute unit usage for different structs / enum (for example, bincode is known to have high compute usage)
  • bloat of a compiled program (for example, borsh is known to make a compiled program huge)
  • ease of use (for example, bytemuck only allows for types that can be represented as bytes)
@alessandrod
Copy link
Contributor

Related issue: solana-labs/solana#23075. solana_prorgam unconditionally pulls in both borsh and bincode, so until that's fixed, all on chain programs that depend on solana_program will be somewhat bloated.

@github-actions github-actions bot added the stale [bot only] Added to stale content; will be closed soon label Aug 10, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale [bot only] Added to stale content; will be closed soon
Projects
None yet
Development

No branches or pull requests

3 participants
@alessandrod @joncinque and others