Freemarker performance questions.

4 messages Options
Embed this post
Permalink
varun.rally

Freemarker performance questions.

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hello,
 
I had a question regarding performance of FreeMarker while generating XML.
 
We have a requirement to populate XML from Java Objects. I created a XML template and populated it from Java objects.
 
My questions:
 
1) If the XML is very big for example(300 MB), will Freemarker be able to handle it, as it caches the templates as well.
 
2) When we call template.process(root, outputStream), does it writes the output xml to the stream alongwith parsing and filling the template with values, or it finishes the complete parsing and then writes it to the stream at once.
 
Please advise.
 
Regards,
Varun
 
 
***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. 
Authorised and regulated by the Financial Services Authority. 
 
This e-mail message is confidential and for use by the 
addressee only. If the message is received by anyone other 
than the addressee, please return the message to the sender 
by replying to it and then delete the message from your 
computer. Internet e-mails are not necessarily secure. The 
Royal Bank of Scotland plc does not accept responsibility for 
changes made to this message after it was sent. 

Whilst all reasonable care has been taken to avoid the 
transmission of viruses, it is the responsibility of the recipient to 
ensure that the onward transmission, opening or use of this 
message and any attachments will not adversely affect its 
systems or data. No responsibility is accepted by The 
Royal Bank of Scotland plc in this regard and the recipient should carry 
out such virus and other checks as it considers appropriate. 

Visit our website at www.rbs.com

***********************************************************************************

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Daniel Dekany

Re: Freemarker performance questions.

Reply Threaded More More options
Print post
Permalink
Tuesday, September 22, 2009, 4:45:57 AM, [hidden email] wrote:

> Hello,
>  
> I had a question regarding performance of FreeMarker while generating XML.
>  
> We have a requirement to populate XML from Java Objects. I created
> a XML template and populated it from Java objects.
>  
> My questions:
>  
> 1) If the XML is very big for example(300 MB), will Freemarker be
> able to handle it, as it caches the templates as well.

It should handle it, but you will need a huge heap... I'm not sure how
big (had to try it), but surely more than 600MB, because the static
text parts are stored as 16 bit (UNICODE) char-s in the memory.

As of the caching, if you don't want to use the template for
multiple-times, you can clear the cache (e.g. with
clearTemplateCache()).

> 2) When we call template.process(root, outputStream), does it
> writes the output xml to the stream alongwith parsing and filling
> the template with values, or it finishes the complete parsing and
> then writes it to the stream at once.

The first one; template.process "streams" the output.

> Please advise.
>  
> Regards,
> Varun

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
varun.rally

Re: Freemarker performance questions.

Reply Threaded More More options
Print post
Permalink
Thanks for your reply...

The static XML istelf will not be 300MB. It will not be very big. But the XML after filling the data is 300 MB.

What I mean is....for example....in the below XML, the static part is very small, but there can be 100000 entries for books within this XML. This is the scenario I wanted to know about, will Freemarker be able to handle it effectively.

<bookslist>
<book>
<name>
<!--names are populated here from java Objects -->
</name>
</book>
 </bookslist>


-----Original Message-----
From: Daniel Dekany [mailto:[hidden email]]
Sent: Tuesday, September 22, 2009 11:02 AM
To: RALLY, Varun, Technology Services India
Cc: [hidden email]
Subject: Re: [Freemarker-devel] Freemarker performance questions.

Tuesday, September 22, 2009, 4:45:57 AM, [hidden email] wrote:

> Hello,
>  
> I had a question regarding performance of FreeMarker while generating XML.
>  
> We have a requirement to populate XML from Java Objects. I created a
> XML template and populated it from Java objects.
>  
> My questions:
>  
> 1) If the XML is very big for example(300 MB), will Freemarker be able
> to handle it, as it caches the templates as well.

It should handle it, but you will need a huge heap... I'm not sure how big (had to try it), but surely more than 600MB, because the static text parts are stored as 16 bit (UNICODE) char-s in the memory.

As of the caching, if you don't want to use the template for multiple-times, you can clear the cache (e.g. with clearTemplateCache()).

> 2) When we call template.process(root, outputStream), does it writes
> the output xml to the stream alongwith parsing and filling the
> template with values, or it finishes the complete parsing and then
> writes it to the stream at once.

The first one; template.process "streams" the output.

> Please advise.
>  
> Regards,
> Varun

--
Best regards,
 Daniel Dekany


***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
Authorised and regulated by the Financial Services Authority.
 
This e-mail message is confidential and for use by the
addressee only. If the message is received by anyone other
than the addressee, please return the message to the sender
by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The
Royal Bank of Scotland plc does not accept responsibility for
changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the
transmission of viruses, it is the responsibility of the recipient to
ensure that the onward transmission, opening or use of this
message and any attachments will not adversely affect its
systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry
out such virus and other checks as it considers appropriate.

Visit our website at www.rbs.com

***********************************************************************************


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Daniel Dekany

Re: Freemarker performance questions.

Reply Threaded More More options
Print post
Permalink
Tuesday, September 22, 2009, 7:39:47 AM, [hidden email] wrote:

> Thanks for your reply...
>
> The static XML istelf will not be 300MB. It will not be very big.
> But the XML after filling the data is 300 MB.
>
> What I mean is....for example....in the below XML, the static part
> is very small, but there can be 100000 entries for books within this
> XML. This is the scenario I wanted to know about, will Freemarker be able to handle it effectively.

Yes, it's not a problem, since FM just immediately dumps whatever it's
done into the Writer and then forgets about it. (Of course, assuming
you are not inside an #attempt block or inside the nested content any
other directive that was specifically written so that it captures the
output.)

> <bookslist>
> <book>
> <name>
> <!--names are populated here from java Objects -->
> </name>
> </book>
>  </bookslist>
>
>
> -----Original Message-----
> From: Daniel Dekany [mailto:[hidden email]]
> Sent: Tuesday, September 22, 2009 11:02 AM
> To: RALLY, Varun, Technology Services India
> Cc: [hidden email]
> Subject: Re: [Freemarker-devel] Freemarker performance questions.
>
> Tuesday, September 22, 2009, 4:45:57 AM, [hidden email] wrote:
>
>> Hello,
>>  
>> I had a question regarding performance of FreeMarker while generating XML.
>>  
>> We have a requirement to populate XML from Java Objects. I created a
>> XML template and populated it from Java objects.
>>  
>> My questions:
>>  
>> 1) If the XML is very big for example(300 MB), will Freemarker be able
>> to handle it, as it caches the templates as well.
>
> It should handle it, but you will need a huge heap... I'm not sure
> how big (had to try it), but surely more than 600MB, because the
> static text parts are stored as 16 bit (UNICODE) char-s in the memory.
>
> As of the caching, if you don't want to use the template for
> multiple-times, you can clear the cache (e.g. with clearTemplateCache()).
>
>> 2) When we call template.process(root, outputStream), does it writes
>> the output xml to the stream alongwith parsing and filling the
>> template with values, or it finishes the complete parsing and then
>> writes it to the stream at once.
>
> The first one; template.process "streams" the output.
>
>> Please advise.
>>  
>> Regards,
>> Varun
>
> --
> Best regards,
>  Daniel Dekany
>
>
> ***********************************************************************************
> The Royal Bank of Scotland plc. Registered in Scotland No 90312.
> Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
> Authorised and regulated by the Financial Services Authority.
>  
> This e-mail message is confidential and for use by the
> addressee only. If the message is received by anyone other
> than the addressee, please return the message to the sender
> by replying to it and then delete the message from your
> computer. Internet e-mails are not necessarily secure. The
> Royal Bank of Scotland plc does not accept responsibility for
> changes made to this message after it was sent.
>
> Whilst all reasonable care has been taken to avoid the
> transmission of viruses, it is the responsibility of the recipient to
> ensure that the onward transmission, opening or use of this
> message and any attachments will not adversely affect its
> systems or data. No responsibility is accepted by The
> Royal Bank of Scotland plc in this regard and the recipient should carry
> out such virus and other checks as it considers appropriate.
>
> Visit our website at www.rbs.com
>
> ***********************************************************************************
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel