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

Add #[speedy(non_exhaustive)] struct attribute #22

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

Conversation

merlleu
Copy link
Contributor

@merlleu merlleu commented Jun 17, 2022

Hello,
I implemented #20, this allows users to have the choice to a little bit less space efficient / slower but be able to append fields to their structs without breaking the parsing of older data.
(this PR also removes the file "log", left in my previous PR).

TODO:

  • basic implementation
  • serialization tests
  • benchmarks

@merlleu
Copy link
Contributor Author

merlleu commented Jun 18, 2022

I forked your serde-bench repo & added NonExhaustive benchmarks: https://github.com/merlleu/serde-bench

@merlleu
Copy link
Contributor Author

merlleu commented Jun 18, 2022

My last commit attempted to reduce the performance delta between non_exhaustive & standard speedy: approx constant+10ns when serializing or deserializing structs.
Unfortunately, switching from varint64 to u7 when possible doesn't seems to be faster using serde-bench.

@merlleu
Copy link
Contributor Author

merlleu commented Jun 18, 2022

Current benchmarks:

test deserialize_manual                       ... bench:          49 ns/iter (+/- 26)
test deserialize_manual_foreign_endianness    ... bench:          53 ns/iter (+/- 27)
test deserialize_serde_bincode                ... bench:         104 ns/iter (+/- 10)
test deserialize_speedy                       ... bench:          66 ns/iter (+/- 11)
test deserialize_speedy_foreign_endianness    ... bench:          65 ns/iter (+/- 11)
test deserialize_speedy_foreign_endianness_ne ... bench:          72 ns/iter (+/- 13)
test deserialize_speedy_ne                    ... bench:          72 ns/iter (+/- 4)
test serialize_manual                         ... bench:          28 ns/iter (+/- 3)
test serialize_manual_foreign_endianness      ... bench:          29 ns/iter (+/- 11)
test serialize_prost                          ... bench:          54 ns/iter (+/- 1)
test serialize_rmp                            ... bench:          68 ns/iter (+/- 8)
test serialize_serde_bincode                  ... bench:          75 ns/iter (+/- 5)
test serialize_serde_cbor                     ... bench:         224 ns/iter (+/- 5)
test serialize_serde_json                     ... bench:         403 ns/iter (+/- 142)
test serialize_serde_pickle                   ... bench:         194 ns/iter (+/- 4)
test serialize_serde_rmp                      ... bench:         178 ns/iter (+/- 12)
test serialize_serde_xdr                      ... bench:          79 ns/iter (+/- 3)
test serialize_speedy                         ... bench:          48 ns/iter (+/- 3)
test serialize_speedy_foreign_endianness      ... bench:          48 ns/iter (+/- 0)
test serialize_speedy_foreign_endianness_ne   ... bench:          52 ns/iter (+/- 3)
test serialize_speedy_ne                      ... bench:          51 ns/iter (+/- 0)

add speedy(non_exhaustive)

rename attrs_c to attrs in Struct::new

add description to readme

switched to varint64 for struct field count && added tests

use u7 instead of varint64 when possible

remove duplicate checks for non_exhaustive

change order of u7 patch
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