Task #7852

Story #7832: migrate from JibX to JAXB for XML binding / codegen

compare performance vs JibX

Added by Rob Nahf almost 6 years ago. Updated almost 6 years ago.

Target version:
Start date:
Due date:
% Done:


Product Version:
Story Points:


JAXB is reportedly slower, as it uses reflection to set up the marshalling context (for each type). the Marshaller and Unmarshaller are not thread safe, but are somewhat expensive to build and throw away. (GC)

TypeMarshaller, for now, has both JAXB and JiBX implemented, to enable comparisons (USE_JIBX property) also has CACHE_CONTEXT and CACHE_MARSHALLERS switches.

Associated revisions

Revision 18250
Added by Rob Nahf almost 6 years ago

refs #7846: refactored types to use new DateMarshallingAdapter. refs #7852: performance testing. Added Marshaller, Unmarshaller caching logic to TypeMarshaller for performance testing, as well as peformance tests to TypeMarshallerTestCase.


#1 Updated by Rob Nahf almost 6 years ago

Using a 7000 item ObjectList, created a unit test that profiles performance of unmarshalling and then remarshalling, repeated 50x.

Test results are the mean and median.

Both JiBX and JAXB have initialization costs associated with them, so I list first and second iteration results. The pairs are the unmarshalling / marshalling values for each line.

first iteration 376 / 184
second 215 / 80
median 42 / 17

JAXB (no caching)
first iteration 700 / 302
second 231 / 117
median 63 / 38

JAXB - caching Context
first iteration 628 / 266
second 203 / 85
median 41 / 19

JAXB - caching Context and (Un)Marshallers
first iteration 657 / 2279
second 177 / 69
median 42 / 20

There is a 50% improvement in caching the Context, but no appreciable difference if we cache the marshallers and unmarshallers themselves.

Caching the JAXB context makes the median unmarshalling and marshalling times equivalent to JiBX, although I'm surprised that not caching the context didn't cause a bigger performance issue. I would have expected no improvement in performance over each iteration. Perhaps the JAXB implementations have some optimizations in built in.

#2 Updated by Rob Nahf almost 6 years ago

Since caching the marshallers and unmarshallers don't add any performance gain, we should remove it to simplify the code base. As per a member of the JAXB 2 expert group (

"JAXBContext is thread safe and should only be created once and reused to avoid the cost of initializing the metadata multiple times. Marshaller and Unmarshaller are not thread safe, but are lightweight to create and could be created per operation."

#3 Updated by Rob Nahf almost 6 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 30 to 100
  • translation missing: en.field_remaining_hours set to 0.0

Removed marshalling and unmarshalling caching, since it did not affect performance.

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 14.8 MB)