Improve sitemesh decoration performance

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Fixed
    • 3.4-m4
    • Component/s: None
    • None

      Each time a sitemesh decorator is applied in Confluence, the content of that decorator is buffered not once but three times. Here is some example offending code:

              StringWriter bodyBuffer = new StringWriter();
              page.writeBody(OutputConverter.getWriter(bodyBuffer));
              context.put("body", bodyBuffer.toString());
      

      So we have:

      1. The original sitemesh page buffer
      2. The StringWriter buffer (which as it grows will copy itself many times over)
      3. The character array in the String array produced by the bodyBuffer

      This happens several times per request, once for the main page and several times as various components use the #applyDecorator velocity directive.

      This need not be the case, velocity has a Renderable interface, that allows you to write directly to velocities writer, without buffering the page into a String, so that each time a decorator is applied, the content is only buffered once.

            Assignee:
            James Roper [Atlassian]
            Reporter:
            James Roper [Atlassian]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: