cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Enke <>
Subject outputBufferSize>0 for pipelines: Xalan must be patched
Date Tue, 27 Mar 2007 09:02:40 GMT
Hi all,
the outputBufferSize as a pipeline parameter doesn't help to push the output early to the
(at least if the document is a small document <16k).

The reason is a BufferedOutputStream which is setup in the serializer (2.7.0)

   /** number of bytes that the byte buffer can hold.
    * This is a fixed constant is used rather than m_outputBytes.lenght for performance.
   private static final int BYTES_MAX=16*1024;

That buffer already was existing in xalan2.5.1 but there a directWrite
wrote out every byte with write(int);
Now the serializer writes out if the buffer is full or at end of document with write(byte[],
int, int).

That means setting the outputBufferSize in sitemap to lower than 16*1024 is senseless
and the comment in
   // FIXME Triple buffering, anyone?
is correct: It makes no sense to buffer here. A value of 0 has the same effect as a value
<= 16*1024.
(In detail the serializer buffer is for serialized bytes, in sitemap it is for pipeline bytes
  which probably is different depending on the stylesheet. I did not investigate how performance
  differs for outputBufferSize=0 or >0)

I use a real time application which has to write html immediately, independent of the number
of bytes.
I use the following (and a Cocoon committer should propose that as a patch to the xalan team):

I add an attribute flush="on" to my xml stream. From now on xalan flushes at every endElement().
If I want to stop that I add an attribute flush="off" to my xml stream.

--- xalan-j_2_7_0.orig/src/org/apache/xml/serializer/  2005-08-06 23:05:30.000000000
+++ xalan-j_2_7_0/src/org/apache/xml/serializer/       2007-03-27 10:48:24.860050168
@@ -749,6 +749,7 @@
       *  @see #endElement
       *  @see org.xml.sax.AttributeList
+    boolean flushAll = false;
      public void startElement(
          String namespaceURI,
          String localName,
@@ -756,6 +757,15 @@
          Attributes atts)
          throws org.xml.sax.SAXException
+        if(atts != null)
+        {
+            String flushAtt = atts.getValue("flush");
+            if(flushAtt != null)
+            {
+                if(flushAtt.equals("on")) flushAll = true;
+                else if(flushAtt.equals("off")) flushAll = false;
+            }
+        }

          ElemContext elemContext = m_elemContext;

@@ -887,6 +897,7 @@
          final String name)
          throws org.xml.sax.SAXException
+        if(flushAll) flushWriter();
          // deal with any pending issues
          if (m_cdataTagOpen)

The same has to applied to

I hope that others find it useful too.


WINCOR NIXDORF International GmbH
Retail Store Solutions
Wernerwerkdamm 16
13629 Berlin, Germany
Phone +49 (0) 30 5017-1386
Fax +49 (0) 30 5017-1305

WINCOR NIXDORF International GmbH
Sitz der Gesellschaft: 33106 Paderborn, Heinz-Nixdorf-Ring 1
Registergericht Paderborn HRB 3507
Geschäftsführer: Eckard Heidloff (Vorsitzender), Stefan Auerbach, Jürgen Wilde, Dr. Jürgen
Vorsitzender des Aufsichtsrats: Karl-Heinz Stiller
Steuernummer: 339/5884/0031
Ust-ID Nr.: DE812927716
WEEE-Reg.-Nr. DE44477193

Diese E-Mail enthält vertrauliche Informationen. Wenn Sie nicht der richtige Adressat sind
diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten
Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential information. If you are not the intended recipient or
have received this e-mail in error, please notify the sender immediately and destroy this
Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly

View raw message