karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bengt Rodehav <be...@rodehav.com>
Subject XML unmarshalling performance in Karaf
Date Tue, 18 Mar 2014 14:28:56 GMT
I'm using karaf 2.3.4 and Camel 2.13.3.

I've been investigating performance problems with Camel's "sjms" component.
Here is the discussion:

http://camel.465427.n5.nabble.com/sjms-and-multiple-threads-td5748836.html

However, at the end I discovered that my real problem was the unmarshalling
of an XML file in Karaf. For some reason, if I unmarshall a certain XML
file it takes about 105 ms in Karaf. If I do the same from my Junit test in
Eclipse it takes around 10 ms. In fact, in Eclipse it starts with around 30
ms but consecutive calls gradually go down to 7-8 ms. In Karaf it doesn't
matter how many times I do the unmarshalling. It stays at about 105 ms
everytime.

I'm very confused about this.

The actual code looks like this (approximately):

  public MmlMessage unmarshallMmlMessage(String theXml) throws
JAXBException {
    final Unmarshaller unMarshaller =
cMmlMessageJAXBcontext.createUnmarshaller();
    StreamSource ss = new StreamSource(new StringReader(theXml));
    long t0 = System.nanoTime();
    JAXBElement<?> mmlMessageElement = unMarshaller.unmarshal(ss,
MmlMessage.class);
    long t1 = System.nanoTime();
    MmlMessage mmlMessage = (MmlMessage) mmlMessageElement.getValue();
    System.out.println("t1: " + (t1-t0) + " ns");
    return mmlMessage;
  }

The MmlMessage class is generated from an XML schema
using maven-jaxb2-plugin. But it shouldn't matter since the same classes
are used within Karaf as outside of Karaf.

I assumed that for some reason I'm not running the same code in Karaf as
outside Karaf. When logging the actual class of the unMarshaller variable I
get: "com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl" both
within and outside Karaf.

The classloader for the unMarshaller in Karaf is:
"org.apache.felix.framework.BundleWiringImpl@5740eacd".

I thought I had the answer when I noted that outside Karaf I use the Jaxb
implementation that is listed in Camel-jaxb dependencies. This is version
2.1.13. In Karaf I had installed a jaxb version from servicemix bundles
namely:

      <groupId>org.apache.servicemix.bundles</groupId>
      <artifactId>org.apache.servicemix.bundles.jaxb-impl</artifactId>
      <version>2.2.1.1_2</version>

So I forced my Junit test to use the same servicemix bundles version but it
was still equally fast as before. No where near the 105 ms I get in Karaf.

I realize that this probably is not a Karaf problem per se. But, I know
there are probably lots of people on this mailing that have handled XML a
lot in Karaf. Do you have any tips on what to look at? What could cause
this performance problem?

/Bengt

Mime
View raw message