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: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: 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 07:32:30 -0400

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




Archive powered by MHonArc 2.6.24.

Top of Page