Skip to main content

How to optimize the performance of FI stream reader/writer?

3 replies [Last post]
Joined: 2007-02-26

We tested data binding using FI stream reader/writer (FI ver 1.2.1) working with JAXB 2.0. To compare, we did the same test using Woodstox xml stream reader/writer with the same JAXB 2.0. The result is as follows (in mini-seconds):

Fast Infoset -- ser: 3.869000 deser: 4.695582
Wstx XML -- ser: 2.167045 deser: 4.164886

FI takes longer time in both serialization and deserailzation. This is a surprise. We expect that FI to be much faster. Are there parameters and/or proerties in FI that we can tune to optimize its performance?

Followings are more detail information about the tests:

The top level test Java bean object is

public class Message {
private String m_subject;
private String m_body;
private HashMap m_recipients; // Map of email address to ContactInfo
... // with all the getters and setters.

public class ContactInfo {
private String m_emailAddress;
private int m_streetNumber;
private String m_streetName;
private String m_city;
private String m_state;
private int m_zip;
... // with all the getters and setters

The test message is a Message object with m_recipient map of 100 ContactInfos. We serialize this object to get the encoded string, then feed this string into deserialization.

Take serialization as example, for FI, we construct the xml stream writer using:

StAXDocumentSerializer writer = new StAXDocumentSerializer();
writer .setOutputStream(out); // out is the output stream.

for Woodstox, we construct the writer as follows:

XMLStreamWriter xmlStreamWriter =

then we use the writer to do marshalling
JAXBContext jc = ...;
Marshaller m = jc.createMarshaller();
m.marshal(obj, writer);



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-01-25

Hello Wayne,

I have several suggestions for you:
1) If it's ok for you - use the latest JAXB2.1, as it's more optimized to work with FI.
2) Reuse XMLStreamWriter and JAXBContext in test (move it outside the testing loop)

Especially think XMLStreamWriter reuse could make sense in comparing. As it appears you recreate FI XMLStreamWriter all the time, but not sure Woodstox factory does it each time also.

Please let me know if it helps or not.


Joined: 2007-02-26

Hi, Alexey,

We are actually using JAXB 2.1. Woodstox factory creates new XMLStreamWriter each time.

Is FI XMLStreamWriter/Reader is thread safe to be reused?

Joined: 2006-01-25

> Is FI XMLStreamWriter/Reader is thread safe to be reused?
No, it's not.

How do you test the perf? You're running serialization/deserialization in loop? Use multithread? If it's possible, can you send the testing code?