Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Re: DOMConverter performance regression

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] Re: DOMConverter performance regression
  • Date: Sat, 02 Oct 2004 14:00:58 -0400

I've made one final change in DOMConverter, and I think this puts DOMConverter performance back in the ballpark of where it was in d25. Briefly, the convert method now keeps a stack of the indexes so it always knows what the current index is, even when moving back up the tree. Therefore it never has to call indexOf. The performance gain is dramatic.

It's something I've been considering for a while, but avoided out of fear of complexity. However, it proved much easier to implement than I thought. I do worry a little that this change might have introduced unforeseen bugs even though it passes all the DOMConverter unit tests so Wolfgang and anyone else using DOMConverter, please do give it a try. The latest code is in CVS. If anyone needs me to build them a JAR file, just holler.

The new variables to manage this are completely local so there shouldn't be any thread safety issues, at least not any that weren't present before. The extra memory usage to manage the stack (which is just an int array I grow as necessary, not even a java.util.Stack) is small compared to the combined sizes of the DOM and XOM documents so that shouldn't kill anybody. It's mathematically provable that any recursive algorithm can be rewritten in a non-recursive fashion, though in the extreme cases you may have to reinvent the call stack to do it. That's close to what I've done here. :-)

--
Elliotte Rusty Harold
elharo AT metalab.unc.edu




Archive powered by MHonArc 2.6.24.

Top of Page