[Mono-dev] Serialization performance + remoting

Rafael Teixeira monoman at gmail.com
Fri Aug 3 10:21:30 EDT 2007


Pablo,

I should add that probably custom serialization should happen at the
Array level, not each element, or you may end experiencing a similar
problem with System.Runtime.Serialization.ObjectIDGenerator.

If you know that all the array elements are different instances (no
repeated references), it will be a huge gain, because that is
something you don't have a way of letting the system provided
serializer know, so it will keep trying to generate ids and check in
the other end to point all references to a single deserialized
instance.

In those cases I normally serialize the whole array into a very
compact and concise blob (forget the fields descriptors or send them
just once) and deserialize at the other end. The added complexity is
paid well in performance, for large sets of objects.

In some cases I go even further and use compression/decompression of
the blob, to achieve even less transport time, I just experiment a bit
to find the right threshold (minimum size) where compression is
beneficial (it is kind of a lookup table one have to construct, to
adjust to the real speed of the connection).

Hope it helps,

On 8/3/07, Mirco Bauer <meebey at meebey.net> wrote:
> On Thu, 2007-08-02 at 22:54 +0200, pablosantosluac wrote:
> > Thanks Mirco,
> >
> > Well, all my objects are already marked as [Serializable] instead of
> > extending the MarshalByRefObject.
>
> Ok, then you are passing the objects by value already.
>
> >
> > So, you mean if I extend the class it will go worse?
>
> Yes :)
> As it will only transfer a proxy object which will always make remoting
> calls for each method or property usage.
> So code like this is very bad:
> for (int i = 0; i < 10; i++) {
>         Console.WriteLine(myRemoteObject.SomeProperty);
> }
> that will cause 10 remoting calls...
>
> >
> > The sample I'm using returns the 4700 objects in a single call (an array is
> > returned)
> Hmmm ok, so you have performance problems with the binary serialization
> itself, not with the remoting/call overhead.
>
> Then you might want to implement custom optimized binary serialization.
> This can be done by implementing the serializable interface yourself. I
> have not done this yet, but I will (for smuxi), as the built in binary
> serialization of objects in MS .NET and Mono is pretty slow (actually
> damn slow IMHO). The problem is that they are very generic
> implementations to fit all cases, AFAIK.
>
> How to implement faster binary serialization check this out:
> http://www.codeproject.com/csharp/FastSerialization.asp
>
> Maybe I will start a SmartBinarySerializer project :-P not sure...
> As there is no free (as in MIT/X11, BSD, LGPL, whatever license)
> implementation of an optimized binary serialization :(
>
> --
> Regards,
>
> Mirco 'meebey' Bauer
>
> PGP-Key:
> http://keyserver.noreply.org/pks/lookup?op=get&search=0xEEF946C8
>
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GIT d s-:+ a-- C++ UL++++$ P L++$>+++$ E- W+++$ N o? K- w++>! O---- M-
> V? PS
> PE+ Y- PGP++ t 5+ X++ R tv+ b+ DI? D+ G>++ e h! r->++ y?
> ------END GEEK CODE BLOCK------
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
>


-- 
Rafael "Monoman" Teixeira
---------------------------------------
"I myself am made entirely of flaws, stitched together with good intentions."
Augusten Burroughs



More information about the Mono-devel-list mailing list