views:

630

answers:

3

We recently upgraded to Castor 1.2 from version 0.9.5.3 and we've noticed a dramatic drop in performance when calling unmarshal on XML. We're unmarshaling to java classes that were generated by castor in both cases. For comparison, using identical XML the time for the XML unmarshal call used to take about 10-20ms and now takes about 2300ms. Is there something obvious I might be missing in our new castor implementation, maybe in a property file that I missed or should I start looking at reverting to the old version? Maybe there was something in the java class file generation that is killing the unmarshal call? I might also consider Castor alternatives if there were a good reason to drop it in favor of something else. We're using java 1.5 in a weblogic server.

A: 

You might want to consider using JiBX instead. It is considerably faster than Castor (9x faster on one project where I made the switch), and cleaner.

EDIT: See also my answer to this related question.

Dan Dyer
+1  A: 

We wound up reverting to Castor version 0.9.5.3 and the performance jumped back up after we regenerated the java classes from the new XSD's. I'm not sure why exactly there's such a big difference between the resulting java but the 1.2 classes were about 2 orders of magnitude slower when unmarshaling.

EDIT:It looks like by creating ClassDescriptorResolvers/mapping file and turing off validation that we could improve the performance also but since we create about 1000 objects with the schema generation process this isn't really viable from a cost perspective.

18Rabbit
A: 

I too have this issue, when generating a basic customer/address set of XML it takes around 3s to generate a document including 74 customers.

Reverting to 1.0.4 (for testing) sees this return to 1.4s,

But hand rolling the XML sees the output at under 40ms.. I know the frameworks add some overhead, but there must be something causing this.

Has there been any profiling run on Castor?

I'll go investigate JiBX as suggested by Dan.

stevemac