How can I optimize serialization time and size of objects?

Attached is a quick test harness showing the difference in both the serialized size and serialization times for three objects, one using Java serialization, one using the Oracle Coherence ExternalizableLite serialization and one using the Oracle Coherence XmlBean framework (with XmlBean serialization optimizations turned on).

Use either com.tangosol.io.ExternalizableLite or com.tangosol.run.xml.XmlBean.

The following sample results are from a1.8 GHz laptop:

Java Serialization -------------> 894 bytes
Tangosol ExternalizableLite ----> 309 bytes
Tangosol XmlBean Serialization -> 201 bytes

Serialized an Value 100,000 times --------> 4607ms
Serialized an ELValue 100,000 times ------> 1151 ms
Serialized an XmlBeanValue 100,000 times -> 761 ms

To use this test, download the attached serialization-test.jar to the Coherence lib directory run java -jar serialization-test.jar.

Make sure you add com.tangosol.examples.coherence.serialization.XmlBeanValue and com.tangosol.examples.coherence.serialization.ChildXmlBeanValue and set enable-xmlbean-class-cache to true in the ExternalizableHelper.xml found in the coherence.jar.

To enable the XmlBean serialization optimizations, use this procedure:

  1. Extract the ExternalizableHelper.xml from the coherence.jar;
  2. Set enable-xmlbean-class-cache to true. For example:
    <enable-xmlbean-class-cache>true</enable-xmlbean-class-cache>
  3. Add xmlbean-class elements for each of your XmlBean classes. For Example:
    <xmlbean-list>
        <xmlbean-class>com.company.MyFirstXmlBeanValue</xmlbean-class>
        <xmlbean-class>com.company.MySecondXmlBeanValue</xmlbean-class>
    </xmlbean-list>
  4. Add the new ExternaliableLite.xml to the coherence.jar. Be sure to maintain the proper directory structure: com/tangosol/util/ExternalizableHelper.xml
  5. Rerun your serialization tests.

Attachments:
serialization-test.jar (application/octet-stream)