4 Replies Latest reply on Apr 5, 2012 2:16 PM by ilocatelli2

    out.print performance problems?

    ilocatelli2 Level 1



      I'm facing strange performance problems I would not expect generating long html pages on the fly.


      I have a page that is approximately 30 to 40Kb long. Profiling code generation I obtain a 30 second time to process. I have excluded every server-side processing activity since I have also used a StringBuffer to accumulate all the html code to be flushed: generating the StringBuffer content require less than 1ms... flushing out the content with:




      is taking 5 to 6 seconds. The same happens both on a development environment using CQ servlet engine, both in production where we are using CQ with JBoss as app server.


      I tried the same operation on a simple tomcat installation with a JSP... less than 10 ms to generate the full page.


      This problem is slowing down a lot performances.


      The contents are generated inside a nested component included with a <cq:include> tag.


      Anyone can give me suggestions on how to cut down a so big delay in html content generation?



        • 1. Re: out.print performance problems?
          justin_at_adobe Adobe Employee

          I don't know if this is the issue, but I'd strongly suggest using a StringBuilder, not a StringBuffer. StringBuffer has additional thread synchronization code which is not necessary in this case.

          • 2. Re: out.print performance problems?
            ilocatelli2 Level 1

            Hi Justin.


            The problem is not in the string buffer / builder (less than 1 ms to produce it) but in the out.flush() operation... the most basic and simple thing... where I really wouldn't expect to have performance issues


            Since I have replicated it both on CQ servlet engine and JBoss+CQ, I mind where can be the problem. Note that I'm using CQ 5.2.1.





            • 3. Re: out.print performance problems?
              justin_at_adobe Adobe Employee

              Sorry for the confusion - your original message implied that the problem was with the print line, which implicitly does a toString() of the StringBuffer. If the problem is with the flush line, that's a different story.

              • 4. Re: out.print performance problems?
                ilocatelli2 Level 1

                I made further analysis and now I can give a clearer scenario.


                The *very low* performances has been registered on CQ 5.2.1 when generating html code full of relative links. Every link *cost* big processing time. With 60-70 links the component ends up paying 3 to 4 seconds (too much!).

                The same component on a CQ 5.4 instance takes approximately 500 milliseconds, still too much considering that without link the same html code is generated in less than 10 milliseconds.


                The reason is clearly in the filters applied in the output pipeline --> link checker? remapping on links based on etc/map configurations?


                How can I change configurations in order to avoid these performance problems?