views:

699

answers:

3

Hi, I am currently using the binary formatter (Remoting) to serialize/deserialize objects for sending around my LAN.

I have recently upgraded from 2.0 to .Net 3.5, has 3.5 introduced any new types to improve serialization performance?

I’ve looked at the DataContractSerializer but this serializes anything to underlying xml right … which must increase the memory footprint.

So my question is; what’s the fastest serializer for sending objects across my LAN? I don’t care a about interop or versioning …. I need speed!

/I am open to 3rd party open source alternatives.

Thanks a lot.

+4  A: 

It sounds like Protocol Buffers might be what you're looking for.

There are three .NET implementations that I'm aware of: protobuf-net, protobuf-csharp-port and Proto#.

The performance comparisons show that Protocol Buffers outperform the built-in serializers in terms of both size and serialization/deserialization speed.

LukeH
+1  A: 

In the performance comparison linked by @Luke, notice that DataContractJsonSerializer performs very well compared to the other MS serializers.

Given the ubiquity of JSON, and the ease of which you can use DataContractJsonSerializer, I don't see much reason to use "protocol buffers". JSON will be easier to debug when bouncing between languages and platforms, and it will compress beautifully.

(I love how Google takes CS 101 concepts and becomes famous for implementing them. In C, we call "protocol buffer" "struct"s. They work great.)

Frank Krueger
+2  A: 

I have some benchmarks for the leading .NET serializers available based on the Northwind dataset.

@marcgravell binary protobuf-net is the fastest implementations benchmarked that is about 7x faster than Microsoft fastest serializer available (the XML DataContractSerializer) in the BCL.

Microsoft's JsonDataContractSerializer is pretty slow - over 9x slower that protobuf-net and over 3.6x slower than my own JsonSerializer.

mythz