[php-src] PR #11376: Fix #79700: Bad performance with namespaced nodes due to wrong libxml assumption
| From: | nielsdos | Date: | Mon, 05 Jun 2023 20:19:21 +0000 |
| Subject: | [php-src] PR #11376: Fix #79700: Bad performance with namespaced nodes due to wrong libxml assumption | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22668@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11376
Author: nielsdos
Fixes https://bugs.php.net/bug.php?id=79700
(that issue description also contains the benchmark!).
The issue talks about a wrong assumption, but I don't think it's a wrong assumption
per-se. See also GH-5719 for more context and the emails from https://mail.gnome.org/archives/xml/2020-June/msg00000.html.
The purpose of oldNs AFAIK is actually to store the namespaces which can't be stored on the
document nodes. They can't be freed because these nodes may be reused (and they don't
refcount or anything). Also: not storing them on the oldNs list will leak memory when all relevant
XML nodes are destroyed.
The problem in the original issue is the ever-growing list of duplicate ns nodes.
This PR solves this.
Commit list:
* Commit 1
Remove redundant assignment on nodep->ns cleans up some code
* Commit 2 Use a prepending strategy instead of appending in dom_set_old_ns() improves
performance of the list management (see commit description).
* Commit 3 Reuse namespaces from doc->oldNs if possible in dom_get_ns() solves the
actual problem by reusing ns nodes.
Targeting master because of potential impact of risky code changes.
Marking as draft for now because I need to double check this stuff.