Multithreaded MobileFormatter

Multithreaded MobileFormatter

Old forum URL: forums.lhotka.net/forums/t/7470.aspx


Jack posted on Tuesday, August 18, 2009

Is there any way to optimize the serialization of large object graphs?

Would it be possible to take a parent object and serialize each of the child lists in a separate thread to speed things up?

Obviously it would be far too complicated to do anything recursively but if I knew in advance that I had a parent object with 4 large collections could there not be gains to be had there?

thanks

jack

tmg4340 replied on Tuesday, August 18, 2009

I'd bet that you'll strike out with this technique.  In order to effectively multi-thread your serialization, you'd probably have to create multiple streams and combine them at the end.  So any optimization you might get from multi-threading the stream creation is going to get eaten up by the merge process, since you have to go back and read the streams you just created.  Trying to share the serialization stream across threads is probably not going to work, as the threads could essentially write the data out of order, and the de-serialization process wouldn't be able to re-construct the objects because the ordering wouldn't be predictable.  In any event, you'd also have to write your serialization code to deal with that situation (i.e. your child-object streams need to know that you are only writing part of a stream, so that you don't create all the serialization header data.)

How large is "large"?

- Scott

Copyright (c) Marimer LLC