Skip to main content

JAXB 2.0 and FastInfoset

6 replies [Last post]
krose
Offline
Joined: 2005-09-01

Web Services are verbose, and I have been tasked to examine what can be gained from various performance enhancing technologies, in order for the services to operate on disadvantaged grids. Eventually selected technologies will be included in a demonstrator.

Our present demonstrator has Web Services buildt around it, but with JAXB 2, the core system could use the generated types and WS could be more directly integrated with the core. I am very pleased with JAXB 2 so far.

In order to examine the size of XML dokuments, and compare them with documents generated by Fast Infoset, I have generated my report classes from a xsd schema describing a report that will eventually be sent by WS. So far I have written a small test program that generates a report object and serializes it to an XML document by:

Report = new Report(.......);
..........
JAXBContext jc = JAXBContext.newInstance("....");
StringWriter sw = new StringWriter();
Marshaller ma = jc.createMarshaller(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal( report, sw);

The size of the XML report is 872 bytes. I want to examine the effectiveness of Fast Infoset when sending 1, 4 and 8 reports in one message.

JAXBB 2.0 is said to have native support for FastInfoset, and my question is how do I invoke it?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bhaktimehta
Offline
Joined: 2004-03-18

Hi,
Try using the
public void marshal(Object obj, XMLStreamWriter writer) method of the Marshaller.

Have FastInfoset.jar in the classpath.

The com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput uses reflection to load the FI classes if it can find them else uses StAX.

Hope that helps.
Regards,
Bhakti Mehta

kohsuke
Offline
Joined: 2003-06-09

As a follow-up to what Bhakti already wrote, I wrote this:
http://weblogs.java.net/blog/kohsuke/archive/2005/09/using_fastinfos.html

krose
Offline
Joined: 2005-09-01

Thanks for the help!

After my first posting I have written my own schema based binary marshaller, in order to get an idea of what can be accomplished with binary encoding.

The results so far is:
XML document size: 908 bytes
FastInfoset size: 764 bytes
Schema based size: 228 bytes

It will be interesting to see the results with FastInfoset when sending several reports in one message.

It was disappointing to see that FastInfoset uses String encoding of floating point numbers!

kirillcool
Offline
Joined: 2004-11-17

Wouldn't you be interested to see FI numbers on something a bit larger than ~900 bytes? Try an average-sized message of your application and compare the different approaches.

krose
Offline
Joined: 2005-09-01

Yes I would. In fact the average-sized report is less than 900 bytes, but a number of reports can be sendt sent in the same message. I expect FI to be more effective with a large number of reports sendt in one message since the "dictionary" is sendt only once.

krose
Offline
Joined: 2005-09-01

I have finished my study of binary XML for the time being. I'm sending a number of similar reports in one message and the results are:

Reports: 1
XML size: 1214 bytes
FI size: 696 bytes
Binary size: 196 bytes

Reports: 4
XML size: 4 451 bytes
FI size: 1 626 bytes
Binary size: 724 bytes

Reports: 256
XML size: 276 761 bytes
FI size: 80 148 bytes
Binary size: 45 076 bytes

This shows that FI performs well for large messages (during busy periods) and the performance during less busy periods is not so important for our application.

We will use JAXB 2.0 and FI for our demonstrator.

Thanks for the assistance!