Skip to content

Use Cow<str> for faster serde decoding, update some deps #10

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sbillig
Copy link

@sbillig sbillig commented Jan 2, 2021

This changes Log's String fields to Cow<str> (in rust), so the values can be borrowed from the buffer when deserializing, rather than copied. The result is a pretty significant speed boost for the serde deserializers, at the cost of some verbosity in the Log structs.

before:

test rmp_serde_deserialize             ... bench:       2,353 ns/iter (+/- 532) = 121 MB/s
test rust_bincode_deserialize          ... bench:       1,830 ns/iter (+/- 249) = 218 MB/s
test serde_json_deserialize            ... bench:       2,858 ns/iter (+/- 422) = 211 MB/s

after:

test rmp_serde_deserialize             ... bench:         531 ns/iter (+/- 141) = 540 MB/s
test rust_bincode_deserialize          ... bench:         320 ns/iter (+/- 73) = 1250 MB/s
test serde_json_deserialize            ... bench:       1,212 ns/iter (+/- 191) = 499 MB/s

I also added some _dynamic benchmarks for rmp and serde_json which de/serialize from/to the libraries' respective dynamic Value enums, to satisfy my curiosity.

test rmp_serde_deserialize_dynamic     ... bench:       1,724 ns/iter (+/- 1,031) = 166 MB/s
test rmp_serde_serialize_dynamic       ... bench:         421 ns/iter (+/- 83) = 681 MB/s
test serde_json_deserialize_dynamic    ... bench:       9,390 ns/iter (+/- 1,925) = 64 MB/s
test serde_json_serialize_dynamic      ... bench:       1,459 ns/iter (+/- 214) = 414 MB/s

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.

1 participant