[xml] Question about xmlDoc->oldNs usage in php



Hi,

so we identified a performance bottleneck in PHPs dom implementation when doing a lot of Element::appendChild calls with namespaced nodes. 

PHPs DOM impl being generic about all kinds of XML use cases, there is a namespace reconciliation whenever appendChild is called, which calls xmlReconciliateNs.

But it does some more, it also iterates the list of namespaces on the node to be added (newNode) and puts these namespaces into xmlDoc->oldNs. There is a mistake in php_dom_set_old_ns I believe where namespaces are not deduplicated, essentially growing the xmlDoc->oldNs list extremely large.

https://github.com/php/php-src/blob/62b1d2c/ext/dom/php_dom.c#L1366-L1420

This code is from 2003, and was only shuffled around since then, but its not clear from the commit messages why it exists.

Now I am wondering what oldNs is even used for here, it seems from the libxml code it is really only needed to "cache" a pointer to the xmlNs that represents "xml" and nothing more.

As such I have a patch for PHP dom ready to remove that whole code fiddling with oldNs: https://github.com/php/php-src/pull/5719

Could someone confirm directly using oldNs is not necessary and can be left for the xmlSearch* functions internally?

greeitngs
Benjamin


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]