dom_reconcile_ns performance (or lack thereof)

  104724
March 14, 2019 19:34 cananian@wikimedia.org ("C. Scott Ananian")
I note that there was some recent discussion about fixing DOMNameSpaceNode
on this list.  I'd like to bring up a (perhaps) related issue: the
dom_reconcile_ns() function which is called whenever a new namespaced node
(for example, created with Document#createElementNS) is inserted into the
tree.  dom_reconcile_ns() does a full walk up to the root of the DOM (via
the call to xmlSearchNsByHref) which can create a quadratic slowdown for
deeply-nested documents.

What is this function doing?  Can we do it lazily?  Technically HTML
elements should be created in the HTML namespace, but doing so leads to
extreme performance loss -- parsing a 2MB file goes from 0.4s (with
Document#createElement()) to 2.5s (with Document#createElementNS()).
  --scott
-- 
(http://cscott.net)
  104781
March 17, 2019 22:59 rrichards@cdatazone.org (Rob Richards)
I'll need to revisit this. Its purpose is to both avoid redundant
namespace declarations as well as avoid internal memory corruption of ns
nodes in documents.
iirc it should only be walking back up the tree to a node that might
have declared the namespace being referenced.

Rob

On 3/14/19 12:34 PM, C. Scott Ananian wrote:
> I note that there was some recent discussion about fixing DOMNameSpaceNode > on this list. I'd like to bring up a (perhaps) related issue: the > dom_reconcile_ns() function which is called whenever a new namespaced node > (for example, created with Document#createElementNS) is inserted into the > tree. dom_reconcile_ns() does a full walk up to the root of the DOM (via > the call to xmlSearchNsByHref) which can create a quadratic slowdown for > deeply-nested documents. > > What is this function doing? Can we do it lazily? Technically HTML > elements should be created in the HTML namespace, but doing so leads to > extreme performance loss -- parsing a 2MB file goes from 0.4s (with > Document#createElement()) to 2.5s (with Document#createElementNS()). > --scott