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 MessagePack-Sharp #2

Merged
merged 1 commit into from
Aug 7, 2017
Merged

Add MessagePack-Sharp #2

merged 1 commit into from
Aug 7, 2017

Conversation

neuecc
Copy link
Contributor

@neuecc neuecc commented Aug 7, 2017

Hi, I'm MessagePack-CSharp author.
I've read your article and comment.
I can't reproduce your comment's exception(Oh...)
https://aloiskraus.wordpress.com/2017/04/23/the-definitive-serialization-performance-guide/#comment-86
But I've added my serializer to your benchmark.

Note: MessagePack for C# does not support private field.

@Alois-xx Alois-xx merged commit 2e15988 into Alois-xx:master Aug 7, 2017
@Alois-xx
Copy link
Owner

Alois-xx commented Aug 7, 2017

Looks good to me. I have merged your changes.
In my test I did add a Key attribute only on the public fields of LargeBook but not the private ones. I think that was the main difference between your and my test. That seemed to break something in MessagePack.

@neuecc
Copy link
Contributor Author

neuecc commented Aug 8, 2017

Thanks, and I will investigate contracts that we do not anticipate.

By the way, I forgot to attach the attribute of [MessagePackObject] here.
https://github.com/neuecc/SerializerTests/blob/c373120079d92b6a98356556fddf1e542a546b0b/TypesToSerialize/LargeBookShelf.cs#L90
This means that is used string key format(it is slow)
If you do measure with LargeObject, I would be happy if you grant it.

@Alois-xx
Copy link
Owner

Alois-xx commented Aug 9, 2017

How would that affect de/serialization? How big would be the speed gain?

@neuecc
Copy link
Contributor Author

neuecc commented Aug 10, 2017

Just another matter, there is a measured code.
MessagePack-CSharp/MessagePack-CSharp#102

Serialize

Method Mean Error StdDev Scaled ScaledSD Gen 0 Allocated
int key 202.5 ns 0.6068 ns 0.5676 ns 1.00 0.00 0.0010 40 B
string key 320.2 ns 0.8527 ns 0.7120 ns 1.58 0.01 0.0015 64 B

Deserialize

Method Mean Error StdDev Scaled ScaledSD Gen 0 Allocated
int key 227.3 ns 1.4442 ns 1.2803 ns 1.00 0.00 0.0042 144 B
string key 439.1 ns 4.2986 ns 4.0209 ns 1.93 0.02 0.0039 144 B

When serializing, int key only write array size header but string key requires each map string key name.

When deserializing, int key can map what type/property to deserialize by switch table but string key requires hashtable lookup.

By the way, if you do a fair serializer speed test, I think that all private fields should be public.
The reason for omitting serialization/deserialization of non-targeted fields is that performance differences arise, which is more advantageous.

@aienabled aienabled mentioned this pull request May 2, 2018
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.

None yet

2 participants