Fast Serialization

Posts   
 
    
matdone
User
Posts: 12
Joined: 02-Oct-2007
# Posted on: 02-Oct-2007 05:38:00   

Hi, I would like to enable fast serialization on my entities but cannot quite see where to do it. I am using HTTP binary remoting with IIS (.net 2.0/SQL 2005).

At the moment I do not explicitly serialize or de-serialize anything, it is all taken care of by the remoting framework.

My execution flow at the moment is like this. 1. Create Remote connection via HTTP (binary) to remoting server from web server. 2. Instantiate single call remotable class (Class inherits from MashalByRefObject) 3. Call method on remotable class. Method will usually return a DataTable or an Entity/Entity Collection. Method will call the DataAccessAdapter class to fetch entities. Both the DataTable and the Entities are serializable already. 4. Bind returned object to datasource of grid or something similar.

Can somebody give me an example of how to go about enabling the fast serialization. And where in the execution flow would I put it. Thanks.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Oct-2007 12:48:23   

To enable FastSerialization you have to set the static property SerializationHelper.Optimization to one of the values of the enum type SerializationOptimization, which is either None (default, use normal BinaryFormatter serialization) or Fast.

You should set it as early as possible in your flow, most probably before step 3. Also this should be called both sides of the serialization (Server & Client).

matdone
User
Posts: 12
Joined: 02-Oct-2007
# Posted on: 03-Oct-2007 06:12:54   

Thanks for that Walaa. I have placed the line SerializationHelper.Optimization = SerializationOptimization.Fast into the method that opens the remoting channel on the client side and I put it in the Remoting Base class constructor that is inherited from all of my classes that will be serialized (Server Side).

One quick one. How do you know that it is working. I have looked in the output with verbose debugging turned on with the following switches but I can seem to see anything that would tell me about the serialization method:

<switches> <add name="SqlServerDQE" value="4" /> <add name="ORMGeneral" value="0" /> <add name="ORMStateManagement" value="0" /> <add name="ORMPersistenceExecution" value="3" /> </switches>

Thanks Again.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 03-Oct-2007 10:34:21   

It's transparent, so you won't see it popping up in the tracers. If you want to see what the differences are, you can serialize to a memory stream and check the buffer size simple_smile . It will be much faster and the size of the data is much smaller

Frans Bouma | Lead developer LLBLGen Pro