Fast Serialization code follow up

Posts   
 
    
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 12-Jan-2007 07:28:41   

Due to unforseen circumstances, I don't have the time currently to write an article or detailed instructions for using the current fast serialization code I have. Or even to merge it in to the latest released version.

What I have created though is a ZIP file containing the current code and a copy of the original file/template from which they were created where there was one. Frans is planning to incorporate a version of this code in v2.1 and so it will eventually be converted for all the other flavours/combinations but I only have NET2.0/C#/Adapter code.

This should be enough to allow anyone who is keen enough to diff the original/new files and work out what I have changed/added (mainly added to no backwards compatibility problems) and incorporate them into a copy of any LLBLGen Runtime source library and compile.

Notes: To switch on Fast Serialization, you just need to set SerializationHelper.Optimization = SerializationOptimization.Fast early at startup time.

By default, ObjectIDs are not preserved during through the serialization/deserialization cycle - any inter-entity references will automatically generate a new ID as required. This saves around 15% in size. However, if you need to preserve the ObjectIDs to be able to match them back to existing entities, just set SerializationHelper.PreserveObjectIDs = true

I have just added a minimally tested option for byte compression. By setting SerializationHelper.Compressor = new XXX() where XXX supports IByteCompressor or IMemoryStreamByteCompressor, the fast serializer/deserializer will compress/decompress the serialized data at the appropriate time. By using an interface to support compression, you can plug in any compression utility external to the LLBLGen runtime library. It should be easy to incorporate .NET 2.0s compression tools but I just haven't got round to it yet so I have included MiniLZO.cs as a sample but be aware that the majority of this code is not mine and is bound by the GNU General public Licence v2. Also it is 'unsafe' code for speed.

Please be aware that the code I have will be passed to Solutions Design at some point and so what is eventually included in v2.1 may be completely different to the attached code.

Cheers Simon

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 12-Jan-2007 10:03:43   

This looks like a very very good feature. Thanks for sharing.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 12-Jan-2007 10:53:17   

Forgot to approve the attachment again. THe attachment is now approved and available. simple_smile (click the paperclip in the topicstartpost)

Frans Bouma | Lead developer LLBLGen Pro
acradyn
User
Posts: 57
Joined: 03-Apr-2004
# Posted on: 18-Jan-2007 00:08:39   

SimmoTech, thanks for sharing this! I'll let you know if I can get it working and how much it helps!

mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 18-Jan-2007 07:02:20   

Whats the best way to get remoting to use this? Just run

SerializationHelper.Optimization = SerializationOptimization.Fast

on both client and server?

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 18-Jan-2007 08:33:46   

mikeg22 wrote:

Whats the best way to get remoting to use this? Just run

SerializationHelper.Optimization = SerializationOptimization.Fast

on both client and server?

Yes, thats the plan.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 16-Mar-2007 05:31:46   
sangla
User
Posts: 2
Joined: 26-Mar-2008
# Posted on: 27-Mar-2008 03:52:47   

simmotech wrote:

I have just added a minimally tested option for byte compression. By setting SerializationHelper.Compressor = new XXX() where XXX supports IByteCompressor or IMemoryStreamByteCompressor, the fast serializer/deserializer will compress/decompress the serialized data at the appropriate time. By using an interface to support compression, you can plug in any compression utility external to the LLBLGen runtime library. It should be easy to incorporate .NET 2.0s compression tools but I just haven't got round to it yet so I have included MiniLZO.cs as a sample but be aware that the majority of this code is not mine and is bound by the GNU General public Licence v2. Also it is 'unsafe' code for speed.

Cheers Simon

I just used SerializationHelper.Optimization = SerializationOptimization.Fast to increase performance. But I don't know how to use Compressor property. Have you got some samples as your code that your posted?

Thanks!

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 27-Mar-2008 10:41:10   

sangla wrote:

simmotech wrote:

I have just added a minimally tested option for byte compression. By setting SerializationHelper.Compressor = new XXX() where XXX supports IByteCompressor or IMemoryStreamByteCompressor, the fast serializer/deserializer will compress/decompress the serialized data at the appropriate time. By using an interface to support compression, you can plug in any compression utility external to the LLBLGen runtime library. It should be easy to incorporate .NET 2.0s compression tools but I just haven't got round to it yet so I have included MiniLZO.cs as a sample but be aware that the majority of this code is not mine and is bound by the GNU General public Licence v2. Also it is 'unsafe' code for speed.

Cheers Simon

I just used SerializationHelper.Optimization = SerializationOptimization.Fast to increase performance. But I don't know how to use Compressor property. Have you got some samples as your code that your posted?

Thanks!

Hi

The GNU General Public License for MiniLZO means that MiniLZO could not be included with LLBLGenPro.

However, if you and your app are comfortable with that license then you can include the MiniLZO source code into your app and then write a simple class that implements IMemoryStreamByteCompressor - all it would have to do for each interface method is pass it through to the corresponding MiniLZO static method. Then simply assign a new instance of your class to Serialization.Compressor on both client and server sides and thats it!

Cheers Simon

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Mar-2008 11:17:29   

Do realize that if you use GPL v3 code in your app, linking IS covered by that license and therefore you've to distribute the sourcecode with your app if you distribute your application, including the runtime library sourcecode. This is possible in v2.5 but won't be possible in v2.6, as we've changed the license a bit (restricted BSD2)

As you just need to compress a byte array, you could look into more friendlier licensed compressor libraries.

Frans Bouma | Lead developer LLBLGen Pro
sangla
User
Posts: 2
Joined: 26-Mar-2008
# Posted on: 28-Mar-2008 03:33:15   

Thank Simon. It's very simple. simple_smile