Question

I am currently using the binary formatter (Remoting) to serialize and 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.

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 third-party open source alternatives.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.)

As I demonstrated in this answer the generated code might be the fastest serializer. However it is in an early stage and still lacks a couple of features that other serializers offer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top