zerompk v0.7.0 has been released!
This release includes several new features and significant performance improvements!
zerompk::Value
zerompk::Value has been added to allow reading values without a schema!
use zerompk::Value;
fn main() -> zerompk::Result<()> {
// {"name": "zerompk", "version": 7}
let data = [
0x82,
0xa4, b'n', b'a', b'm', b'e',
0xa7, b'z', b'e', b'r', b'o', b'm', b'p', b'k',
0xa7, b'v', b'e', b'r', b's', b'i', b'o', b'n',
0x07,
];
let value: Value<'_> = zerompk::from_msgpack(&data)?;
if let Value::Map(entries) = &value {
for (key, value) in entries {
println!("{key:?}: {value:?}");
}
}
Ok(())
}
While this functionality exists in libraries like rmp-value and msgpacker, this implementation is significantly faster. The following benchmarks show the processing speeds for parsing the msgpack binaries corresponding to the JSON data below.
{
"name": "zerompk",
"active": true,
"version": 6,
"ratio": 1.25,
"tags": ["messagepack", "rust", "zero-copy", "no-std"],
"authors": [
{"name": "Alice", "commits": 127, "active": true},
{"name": "Bob", "commits": 63, "active": false},
{"name": "Carol", "commits": 255, "active": true}
],
"metrics": {
"downloads": [1, 127, 128, 255, 256, 65535, 65536],
"latencies": [0.25, 1.5, 12.75, 100.125],
"nullable": null
}
}
| Library |
Type |
µs/iter |
Throughput |
zerompk |
zerompk::Value |
676.11 |
406 MB/s |
msgpacker |
serde_json::Value |
1,407.18 |
195 MB/s |
rmpv |
rmpv::Value |
1,513.16 |
181 MB/s |
zerompk::read_msgpack_bufread()
Adds a new entry point that supports std::io::BufRead. This implementation is specialized for BufRead and is faster than the standard read_msgpack().
The following are the results of a benchmark for deserializing a msgpack binary file representing an array containing 1,000 instances of Point { x: i32, y: i32 }.
| API |
µs/iter |
read_msgpack_bufread |
4.93 |
read_msgpack |
11.20 |
Performance Improvements
I have completely overhauled the implementation and significantly improved performance! Below is a comparison with the previous version, v0.6.
| Benchmark |
0.6.1 |
0.7.0 |
Diff |
deserialize_array_complex_zerompk |
46.29 |
44.84 |
-3.13% |
deserialize_map_complex_zerompk |
54.45 |
55.95 |
+2.76% |
deserialize_map_long_key_complex_zerompk |
56.25 |
54.50 |
-3.12% |
deserialize_zerompk_file |
11.76 |
11.22 |
-4.56% |
deserialize_large_array_zerompk |
4,299.69 |
2,306.65 |
-46.35% |
deserialize_simple_zerompk |
4.24 |
1.09 |
-74.34% |
deserialize_zero_copy_zerompk |
10.36 |
8.91 |
-14.04% |
serialize_zero_copy_zerompk |
7.46 |
7.75 |
+3.94% |
serialize_array_complex_zerompk |
12.43 |
10.75 |
-13.48% |
serialize_map_complex_zerompk |
18.00 |
11.88 |
-34.01% |
serialize_zerompk_file |
11.61 |
7.04 |
-39.41% |
serialize_large_array_zerompk |
2,588.26 |
2,059.41 |
-20.43% |
serialize_simple_zerompk |
1.49 |
1.49 |
+0.08% |
Have fun!