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 or

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:
  3. Add xmlbean-class elements for each of your XmlBean classes. For Example:
  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.

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