users@jaxb.java.net

Re: Optimizing JAXB RI Marshal performance (solved)

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Mon, 24 Sep 2012 10:18:39 -0400

The issue was determined to be unrelated to JAXB marshalling and was due
to database access occurring during marshall to fetch lazy initialized
collection members. Thank you Wolfgang and Laroslav for your very
helpful suggestions.

On 09/24/2012 03:41 AM, Iaroslav Savytskyi wrote:
> Hi,
>
> You can try to initialize collections before calling the marshalling.
> (e.g. calling size() ). Perhaps this will help to find the bottleneck.
>
> --
> Yaroslav
>
>
> On 21/09/12 19:48, Farrukh Najmi wrote:
>> Hi Wolfgang,
>>
>> Please see inline below (and thanks for your help)...
>>
>> On 09/21/2012 12:39 PM, Wolfgang Laun wrote:
>>> Also, how many fields are there to be marshalled, in the POJO and any
>>> contained objects?
>>
>> Please see a copy of the POJO XML here:
>>
>> http://www.wellfleetsoftware.com/files/tmp/big-auditable-event.xml
>>
>> There are many contained fields including collections that have a few
>> hundred members.
>>
>> I noticed in debugger that if I do two back to back marshals of same
>> object then second time is very fast.
>> This made me realize that the POJO was created by hibernate with lazy
>> init of collections whichh required db access the first time but not the
>> second time.
>>
>> So perhaps this is not a JAXB issue after all?
>>
>>>
>>> On 21/09/2012, Wolfgang Laun <wolfgang.laun_at_gmail.com> wrote:
>>>> How big is the resulting XML?
>>
>> 27KB
>>
>>>> On 21/09/2012, Farrukh Najmi <farrukh_at_wellfleetsoftware.com> wrote:
>>>>> (Resending with subject corrected... Please reply to this thread
>>>>> instead
>>>>> of previous one)
>>>>>
>>>>> Hi Guys,
>>>>>
>>>>> I am observing a 5 second delay in marshalling a POJO to XML using
>>>>> JAXB
>>>>> / JAXB-RI 2.2.3.
>>>>>
>>>>> The size of the POJO is 27K (measured by writing to file). The
>>>>> marshaling was to a StringWriter using code like this:
>>>>>
>>>>> JAXBElement elem = ...
>>>>> if (elem != null) {
>>>>> StringWriter sw = new StringWriter();
>>>>> marshaller.marshal(elem, sw);
>>>>> }
>>>>>
>>>>> This seems excessive a delay but I have nothing to compare it to. Any
>>>>> thoughts on whether this seems reasonable?
>>>>> Are there any tricks to speed this up? Thanks for your help.
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Farrukh Najmi
>>>>>
>>>>> Web: http://www.wellfleetsoftware.com
>>>>>
>>>>>
>>
>>
>


-- 
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com