Performance of Servicestack.Text TypeSerializer

148 views
Skip to first unread message

Sathyamurthy V

unread,
Jul 19, 2012, 8:11:52 AM7/19/12
to servic...@googlegroups.com
We are trying to compare the performance of TypeSerializer to .Net BCL DatacontractSerializer and we are getting weird results. We have a requirement to serialize huge object model, send across the wire and deserialize back to object model. The serialized string in xml format comes to 22 MB. So you can assume the size of object model we are trying to serialize and deserialize. The object model has lot of nesting so the hierarchy goes several level deep. ok, now the results. The time is given in seconds for one serialization and one deserialization.

DataContractSerializer(using XMLDictionaryWriter's CreateBinaryWriter for writing the output): 
Serialization : 00:00:01.2203660
Deserialization : 00:00:02.1886564 (using XMLDictionaryReader's CreateBinaryReader for reading )

DataContractSerializer(using XMLDictionaryWriter's Create Method for writing the output):  
serialization: 00:00:01.8005400
Deserialization : 00:00:01.7435229 (using XMLDictionaryReader's Create Method for reading)

DataContractSerializer(using XMLWriter):   
serialization : 00:00:01.7465238
Deserialization : 00:00:01.7225166 (using XMLReader for reading)

TypeSerializer
serialization : 00:00:02.4687404
Deserialization : 00:00:06.1278378

Based on this results it looks like DataContractSerializer is performing better here. Can you throw any light into this and suggest how to get the better performance with TypeSerializer? is there any know issue that TypeSerializer is slow is handling any type of objects? I was really hoping that TypeSerializer will help us improving the performance but disappointed with the results. The serialized file is huge so I'm not attaching here.

Demis Bellot

unread,
Jul 19, 2012, 9:54:02 AM7/19/12
to servic...@googlegroups.com, servic...@googlegroups.com
As you can imagine without being able to reproduce what's happening we can't tell you anything. Without which we have no idea you're actually doing an Apples to Apples comparison or have verified the results being correct. Are you deserializing the entire payload into an object for all serializers?

If you don't want to send over the file, send over some code that generates the 22mb file using the same types with sample data.

Note: There is a 1 time warmup cost for prepping the delegate caches which is avoided for subsequent runs which should be factored out.

D.B
Sent from my iPad

Brannon

unread,
Jul 19, 2012, 6:09:49 PM7/19/12
to servic...@googlegroups.com
I'd like to see you include BinaryFormatter in your test. What are the output sizes per test? And are you using your own hand-coded dictionary with the DataContractSerializer?

Sathyamurthy V

unread,
Jul 30, 2012, 7:29:26 AM7/30/12
to servic...@googlegroups.com
Hello Demis,
         Thanks for your response. I'm sorry I took sometime to prepare a working sample where you can check my observations. I had to remove some code and massage the serialized xml file. Since the sample is more than 5 Meg I could not attach here. Please download the sample using the link https://www.transferbigfiles.com/1aeb4366-4cf5-4078-8d74-1e9158517d28?rid=DbvmOo9JOg2ZuXgzCTiZ2A2. Sample contains serialized payload as well. please unzip the .rar file and run the console app.

Thanks
Sathya 
Reply all
Reply to author
Forward
0 new messages