Bug #77894 [NEW]: DOMNode::C14N() very slow on generated DOMDocuments even after normalisation

From: Date: Mon, 15 Apr 2019 10:19:16 +0000
Subject: Bug #77894 [NEW]: DOMNode::C14N() very slow on generated DOMDocuments even after normalisation
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220457@lists.php.net to get a copy of this message
From: luxian dot m at gmail dot com Operating system: PHP version: 7.3.4 Package: DOM XML related Bug Type: Bug Bug description:DOMNode::C14N() very slow on generated DOMDocuments even after normalisation Description: ------------ Calling DOMNode::C14N() is way slower on DOMDocument objects that are created on the fly compared to DOMDocuments loaded from a string file. Calling DOMDocument::normalizeDocument() doesn't make a difference despite the documentation stating: "This method acts as if you saved and then loaded the document, putting the document in a "normal" form." But in the end it's still way faster to get the XML string and load it in a new DOMDocument - which is counter intuitive. Code to demonstrate this can be found here: https://gist.github.com/Luxian/1c732d13c12ca03835828a1553c39e4f https://3v4l.org/1fFB3 (limited to 200 items to not abuse the platform) If you run the example code with 500 items you should get something like this: Testing with 500 items Generated DOM… 2.56458 seconds Generated DOM with normalizeDocument()… 2.60349 seconds Export and re-import DOM… 0.06695 seconds Test script: --------------- https://gist.github.com/Luxian/1c732d13c12ca03835828a1553c39e4f Expected result: ---------------- $oldDom->normalizeDocument() // should be the same as $newDom->loadXML($oldDom->saveXML()); Actual result: -------------- 40x worse performance when calling C14N() -- Edit bug report at https://bugs.php.net/bug.php?id=77894&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77894&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77894&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77894&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77894&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77894&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77894&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77894&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77894&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77894&r=support Expected behavior: https://bugs.php.net/fix.php?id=77894&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77894&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77894&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77894&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77894&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77894&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77894&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77894&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77894&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77894&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77894&r=mysqlcfg

« previous php.bugs (#220457) next »