asynkron / Wire

Binary serializer for POCO objects
Apache License 2.0
376 stars 63 forks source link

Speedup dials to compare performance with bond simple binary protocol. #140

Closed ofirgeller closed 3 years ago

ofirgeller commented 7 years ago

I'm compering Wire to bond for my specific use case, so far bond is about 10% faster serializing and about 25% deserializing on a cold start. the difference grows after the first run.

Use case: One wrapper object that has about 20 collections each containing between 10s-10,000s objects (~150,000 in total) of moderate complexity (no nested objects, 4-12 properties).

1 to 5 such wrapper objects are serialized and deserialized when testing (to measure warm-up effect).

Bond settings: I Use the simple binary protocol that is the fastest and most comparable as it also is an "un-tagged" protocol where you do not store scheme data in the output of serialization. I use the recommended OutputBuffer, and I have a good idea of the expected size to I set the capacity accordingly.

Wire use and settings:

  1. I pass in a list of all the types that are in the object, including the type of the parent object(big improvement).
  2. I added to this list all the enum types, (some improvement).
  3. Made sure preserveObjectReferences is false when creating the serializer (no change, already the default).
  4. Made sure versionTolerance is false when creating the serializer (no change, already the default).
  5. I know the expected size and so I set the memory stream capacity in advance(no change).

Weak point in test: Bond allows me to ignore some fields, and I do ignore some. So Wire is doing more work, however it is work that I do not want done and can find no way of preventing. it also does not explain the big diff in performance, we are talking about 8 extra fields out of 220 that I made sure are set to the default value for the test (null/0/false).

What I would like to know is if there are any additional things I can do to give Wire a leg up. I do not mind adding more compile time metadata if that would help. I plan to maintain code for both and re-test every time a new version is out to make sure I'm going with the fastest one for my specific case.

Bond version: 5.3.1 Wire version: 0.8.2 OS: windows 8.1 64 bit. Framework: dotnet 4.6.1