Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] More parsing performance patches

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Michael Kay" <mike AT saxonica.com>
  • To: "'Elliotte Harold'" <elharo AT metalab.unc.edu>, "'Wolfgang Hoschek'" <whoschek AT lbl.gov>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] More parsing performance patches
  • Date: Fri, 22 Jul 2005 17:42:22 +0100

Another case to consider is where the events are coming from the output of
an XSLT transformation, where it's quite likely that each <xsl:value-of>
instruction or piece of literal text in the stylesheet will lead to a call
on characters().

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: xom-interest-bounces AT lists.ibiblio.org
> [mailto:xom-interest-bounces AT lists.ibiblio.org] On Behalf Of
> Elliotte Harold
> Sent: 22 July 2005 12:33
> To: Wolfgang Hoschek
> Cc: xom-interest AT lists.ibiblio.org
> Subject: Re: [XOM-interest] More parsing performance patches
>
> The second new optimization I see here is avoiding the creation of
> intermediate string buffers for most calls to characters. Your
> measurements match my expectations that most of the time there'll be
> exactly one call to characters() per call to flushText(). The
> exceptions
> tend to occur on a few corners:
>
> 1. Documents with very large (16K+) runs of plain, unmarked up text
> 2. A few parsers that call characters separately for entity and/or
> character references
> 3. One particularly brain-damaged older version of Xerces
> that actually
> invoked the characters() method once for each and every character in
> plain text that was loaded from entity references
> 4. A few parsers may call characters separately when a CDATA section
> interrupts non-CDATA section text
>
> Only #1 is really worth considering when optimizing, and even that's
> uncommon.
>
> The basic idea looks good. Given that more than one call to
> characters
> per text, I wonder if we can simplify it somewhat. Suppose we ignored
> StringBuffers completely? In other words, if characters was called a
> second or third time we just append directly to the string?
> This would
> leave the code about as simple as it is now, maybe simpler; and still
> take the same path as your patch for the 99% case where
> characters() is
> only called once. The hit wouldn't even be too bad when
> characters() was
> called more than once, because it almost never would be
> called more than
> two or three times. (Aside from the very weird #3 where performance
> would be abysmal, but honestly that really requires an
> updated parser.)
>
> --
> ?Elliotte Rusty Harold elharo AT metalab.unc.edu
> XML in a Nutshell 3rd Edition Just Published!
> http://www.cafeconleche.org/books/xian3/
> http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/
ref=nosim
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest
>






Archive powered by MHonArc 2.6.24.

Top of Page