-
Notifications
You must be signed in to change notification settings - Fork 684
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
Switch serialization #1166
Comments
Here are some more benchmarks: erickt/rust-serialization-benchmarks#7 FlatBuffers do quite well. I recall we have had an issue with bincode performance. |
Notes on protobuf not being deterministic:
Flatbufs are not deterministic: |
Bincode - is very basic serialization format but at the same time has performance issues due to visitor pattern inside the |
CBOR is a bit slower than Bincode, and is actually self-descriptive. Which we don't really need (and it adds extra wire bytes). Alternative is just using a simple serialization scheme:
We already use this in store/trie as it gave 2x improvement over bincode. This is similar to Simple Serialization suggested by Vitalik here - https://github.com/ethereum/beacon_chain/blob/master/ssz/ssz.py |
FlatBuffers aren't deterministic: |
Just keep in mind that the deserialization should be secure (e.g. if there is a field storing a length of an array, we should check that the number is sane and the array would fit into memory). |
Performance improvement ideas: Speed-up serialization Speed-up deserialization |
It seems that |
It seems like speedy has a different set of priorities than us. Speedy optimizes for speed above all. While our serializer optimizes for consistency of binary representation, safety, and only then speed. As the result our code does not contain |
Started BORsh & implemented it - https://github.com/nearprotocol/borsh |
Moving details of the spec from near/nearcore#1166 to here.
Moving details of the spec from near/nearcore#1166 to here.
Unfortunately protos are not deterministicly serialized across languages and platforms.
We also not using the main benefits of the protos, e.g. upgradability and backward compatibility. Because if the transaction or block proto changes, all the responsible nodes must compute the same state transition, meaning must run the same code.
Also it's known that Bincode is faster than protos. We also added CBOR for comparison:
https://gist.github.com/ilblackdragon/88ab377bf0da7ff721af80cb8a11fe28
Generally, CBOR has support across many languages and a proper standard. Bincode is more specific to the Rust and still doesn't have formal specification.
The text was updated successfully, but these errors were encountered: