Flexible, Fast & Compact Serialization with RPC
Github | Crates.io | Documentation
The stable Rust implementation is pinned to no_proto 0.9.60. The experimental 0.10.0 refactor has been abandoned so future work can focus on a language-neutral NoProto specification and compatible implementations.
Repository layout:
no_proto_rs/ - stable Rust crate and current reference implementation.no_proto_js/ - existing Rust/WASM JavaScript package.packages/ - home for native language implementations such as JavaScript, PHP, and Go.spec/ - shared NoProto format and schema specification.conformance/ - cross-language compatibility test plan and fixtures.bench/ - Rust benchmark suite.Lightweight
no_std support, WASM readyStable
Easy
Fast
Powerful
Compiled formats like Flatbuffers, CapN Proto and bincode have amazing performance and extremely compact buffers, but you MUST compile the data types into your application. This means if the schema of the data changes the application must be recompiled to accomodate the new schema.
Dynamic formats like JSON, MessagePack and BSON give flexibilty to store any data with any schema at runtime but the buffers are fat and performance is somewhere between horrible and hopefully acceptable.
NoProto takes the performance advantages of compiled formats and implements them in a flexible format.
Byte Wise Sorting Ever try to store a signed integer as a sortable key in a database? NoProto can do that. Almost every data type is stored in the buffer as byte-wise sortable, meaning buffers can be compared at the byte level for sorting without deserializing.
Primary Key Management Compound sortable keys are extremely easy to generate, maintain and update with NoProto. You don't need a custom sort function in your key-value store, you just need this library.
UUID & ULID Support NoProto is one of the few formats that come with first class suport for these popular primary key data types. It can easily encode, decode and generate these data types.
Fastest Updates NoProto is the only format that supports all mutations without deserializng. It can do the common database read -> update -> write operation between 50x - 300x faster than other dynamic formats. Benchamrks
Compared to Apache Avro
Far more space efficient
Significantly faster serialization & deserialization
All values are optional (no void or null type)
Supports more native types (like unsigned ints)
Updates without deserializng/serializing
Works with no_std.
Safely handle untrusted data.
Compared to Protocol Buffers
Comparable serialization & deserialization performance
Updating buffers is an order of magnitude faster
Schemas are dynamic at runtime, no compilation step
All values are optional
Supports more types and better nested type support
Byte-wise sorting is first class operation
Updates without deserializng/serializing
Safely handle untrusted data.
All values are optional and can be inserted in any order.
Compared to JSON / BSON
Far more space efficient
Significantly faster serialization & deserialization
Deserializtion is zero copy
Has schemas / type safe
Supports byte-wise sorting
Supports raw bytes & other native types
Updates without deserializng/serializing
Works with no_std.
Safely handle untrusted data.
Compared to Flatbuffers / Bincode
Data types can change or be created at runtime
Updating buffers is an order of magnitude faster
Supports byte-wise sorting
Updates without deserializng/serializing
Works with no_std.
Safely handle untrusted data.
All values are optional and can be inserted in any order.
| Format | Zero-Copy | Size Limit | Mutable | Schemas | Byte-wise Sorting |
|---|---|---|---|---|---|
| Runtime Libs | |||||
| NoProto | ✓ | ~4GB | ✓ | ✓ | ✓ |
| Apache Avro | ✗ | 2^63 Bytes | ✗ | ✓ | ✓ |
| JSON | ✗ | Unlimited | ✓ | ✗ | ✗ |
| BSON | ✗ | ~16MB | ✓ | ✗ | ✗ |
| MessagePack | ✗ | Unlimited | ✓ | ✗ | ✗ |
| Compiled Libs | |||||
| FlatBuffers | ✓ | ~2GB | ✗ | ✓ | ✗ |
| Bincode | ✓ | ? | ✓ | ✓ | ✗ |
| Protocol Buffers | ✗ | ~2GB | ✗ | ✓ | ✗ |
| Cap'N Proto | ✓ | 2^64 Bytes | ✗ | ✓ | ✗ |
| Veriform | ✗ | ? | ✗ | ✗ | ✗ |
…Schemas - Learn how to build & work with schemas.Factories - Parsing schemas into something you can work with.Buffers - How to create, update & compact buffers/data.RPC Framework - How to use the RPC Framework APIs.Data & Schema Format - Learn how data is saved into the buffer and schemas.While it's difficult to properly benchmark libraries like these in a fair way, I've made an attempt in the graph below. These benchmarks are available in the bench folder and you can easily run them yourself with cargo run --release.
The format and data used in the benchmarks were taken from the flatbuffers benchmarks github repo. You should always benchmark/test your own use case for each library before making any choices on what to use.
Legend: Ops / Millisecond, higher is better
| Format / Lib | Encode | Decode All | Decode 1 | Update 1 | Size (bytes) | Size (Zlib) |
|---|---|---|---|---|---|---|
| Runtime Libs | ||||||
| NoProto | ||||||
| no_proto | 1393 | 1883 | 55556 | 9524 | 308 | 198 |
| Apache Avro | ||||||
| avro-rs | 156 | 57 | 56 | 40 | 702 | 337 |
| FlexBuffers | ||||||
| flexbuffers | 444 | 962 | 24390 | 294 | 490 | 309 |
| JSON | ||||||
| json | 609 | 481 | 607 | 439 | 439 | 184 |
| serde_json | 938 | 646 | 644 | 403 | 446 | 198 |
| BSON | ||||||
| bson | 129 | 116 | 123 | 90 | 414 | 216 |
| rawbson | 130 | 1117 | 17857 | 89 | 414 | 216 |
| MessagePack | ||||||
| rmp | 661 | 623 | 832 | 202 | 311 | 193 |
| messagepack-rs | 152 | 266 | 284 | 138 | 296 | 187 |
| Compiled Libs | ||||||
| Flatbuffers | ||||||
| flatbuffers | 3165 | 16393 | 250000 | 2532 | 264 | 181 |
| Bincode | ||||||
| bincode | 6757 | 9259 | 10000 | 4115 | 163 | 129 |
| Postcard | ||||||
| postcard | 3067 | 7519 | 7937 | 2469 | 128 | 119 |
| Protocol Buffers | ||||||
| protobuf | 953 | 1305 | 1312 | 529 | 154 | 141 |
| prost | 1464 | 2020 | 2232 | 1040 | 154 | 142 |
| Abomonation | ||||||
| abomonation | 2342 | 125000 | 500000 | 2183 | 261 | 160 |
| Rkyv | ||||||
| rkyv | 1605 | 37037 | 200000 | 1531 | 180 | 154 |
Vec.Vec into all fields.No open issues yet, or sync has not completed.