“Faster” Serialization
as i´m gonna be involved in building a System that has some significantly complex aggregated Data Objects to serialize frequently, i came across http://jboss.org/serialization/.
this one actually promises some kind of performance gain over plain java serialization …
Recently we discovered that most of the problems in JavaSerialization are related to static synchronized caching, what causes CPU spikes and also diminishes scaling capabilities.
With JBossSerialization we have done internal benchmarks and we have realized at least 2 times faster serialization with this library.
Mum has taught us well to never believe the man offering candy, so let´s have a closer look:
| Java | | copy | | ? |
class BigComplexObject implements Serializable |
{ |
String foo; |
transient String bar; |
int x = 1; |
Map m = new HashMap(); |
List l = new ArrayList(); |
List l2 = new ArrayList(); |
List l3 = new ArrayList(); |
} |
prepared like:
| Java | | copy | | ? |
b = new BigComplexObject(); |
b.foo = "foo"; |
b.bar = "bar"; |
b.x = 17; |
for (int i = 0; i < 10000; i++) |
{ |
StringIdentifier si = new StringIdentifier(UUID.randomUUID().toString()); |
b.m.put("key" + i, si); |
b.l.add(si); |
b.l2.add(si); |
b.l3.add(si); |
} |
// note: StringIdentifier is just a Wrapper holding a String. |
being serialized through JBossObjectOutputStream or ObjectOutputStream respectively to a preconfigured byte-array, looks like in fact the JBoss variant is about 50% slower than the current jdk. i tried hard to change the object (adding/removing multiple references etc) but it did not change anything. Ok, my setup could be wrong, but as this is quite near to my actual usecase, this is it.
for the record, this lib is from 2006. it might have been good back then. if you have any suggestion, where/how jboss ser might still rock against the regular one: i´m listening…
setup: jdk1.6, win32, jboss ser 1.1.beta
mum was right, no candy today…


perhaps you want to look at this one:
http://cornelcreanga.com/2009/07/java-serialization-versus-amfhessian-serialization/
nice. i´m gonna try hessian and post back. thanks.
Update: tested Hessian:
JBossSerializer: 1344ms (Size: 849289 bytes)
HessianSerializer: 1140ms (Size: 1239018 bytes)
PlainSerializer: 985ms (Size: 699312 bytes)
PlainGZipSerializer: 1328ms (Size: 306680 bytes)
not only plain is faster, but it also is significantly more compact.
I think there is a bug in the hessian serialization algorithm, in your case it’s not able to detect that the objects from the lists are identical. However I’ve tried also AMF3 and is faster that plain java serialization, maybe it worth to give it a try.
Thanks. i´ll try the AMF3 serialization lateron and post back, promised.
Where to get the minimal code to use AMF3 serialization? i don´t have to grab the whole 170mb BlazeDS source, do i?
Take a look here: http://cornelcreanga.com/docs/testprotocols.zip
You will find an Intellij project – it has the required libs+sample code how to use the AMF3 serialization
thanks!
i´ll post another article about it. see /blog/2009/09/amf-serialization-followup-faster-serialization/