DbSyncProvider WCF Based Synchronization– Memory Performance Analysis Of DataSet Binary SerializationFormat Vs DataSet Surrogates
I had posted earlier about the memory performance when using default DataSet serialization behavior vs. using a Surrogate. Users had some questions on how the DataSet surrogate compared with the DataSet’s Remoting SerializationFormat. With .Net Fx 2.0 DataSet shipped support for serializing DataSet in Binary in addition to the default XML format. I decided to do a quick test comparing the serialization memory usage between the two optimizations. Here is a simple table detailing the memory usage.
I used a Toshiba Tecra laptop running Windows 7 Beta build with 2GB RAM. The DataSet contains one DataTable which contains one string column. Each column is a 5Mb string. Size is Peak working set. The BinaryFormatter serializes the DataSet in to a MemoryStream.
No of Rows | BinaryFormat Serialization (MB) | Surrogate Serialization (MB) |
1 | 34.1 | 34.5 |
5 | 131.6 | 131.39 |
10 | 271.1 | 271.39 |
48 | 1116.1 | 1118.1 |
50 | Out of Memory | 1024 |
51 | Out Of Memory | Out Of Memory |
As you can see the memory performance is pretty similar to both the options but the Surrogate approach is able to handle slightly more data than the Binary format. The Binary format peaked at 48 rows while the Surrogate approach peaked at 50 rows. I like the Surrogate approach as it gives the users complete control on the way data is serialized and has option for further user defined optimizations. Further the option to pick DataSet Binary serialization format is not available in the Compact framework which means Surrogates might be the only viable option (as opposed to writing a new serializer) for devices. Next I will compare the wire size of the actual serialized data.
Here is the link for original Microsoft KB article on the Surrogate approach. https://support.microsoft.com/kb/829740.
Comments
Anonymous
April 16, 2009
Do you have an example you could post of using the SerializationFormat=binary with the sync framework 1.0 and sync services for ado.net 2.0?Anonymous
April 23, 2009
Yea an example would be extremely helpful. Its unclear in your post sample how or where to do the surrogateDataset translation. Some help with this would be great. -Thanks