Skip to content

Fast Serialization Overview

tylerje edited this page Oct 23, 2014 · 2 revisions

ServiceWire serializes simple value types much faster than complex types. Complex types are serialized to a byte array using .NET's BinaryFormatter and they must therefore be marked as Serializable.

These types from the System namespace serialize very fast without the use of the BinaryFormatter are:

 bool      
 byte      
 sbyte     
 char      
 decimal   
 double    
 float     
 int       
 uint      
 long      
 ulong     
 short     
 ushort    
 string    
 Type      
 Guid      
 DateTime
And of course, arrays of all of these types are equally serialized in line, without the use of the BinaryFormatter.

Special case: null
ServiceWire supports very fast serialization of objects that are null. Of course, the BinaryFormatter does not support serializing a null object. But a null object is never passed to the BinaryFormatter. A simple parameter type 8 bit value is defined to signal the underlying channel and host that the object type should be initialized with a null value at deserialization time.

About BinaryFormatter
There are some libraries that claim to perform binary serialization faster or smaller than the BinaryFormatter. The author has tried a few and found them to be woefully lacking in reliability. For very large, complex objects, the BinaryFormatter may not perform well. In that case, it is recommended that you implement custom serialization and transmit your data as a byte array.

Clone this wiki locally