Skip to content

Potential performance issue with DOM in JIT #16435

@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
$GLOBALS['_start_time'] = microtime(true);
function test_document_import() {
    $xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<div xmlns="http://www.w3.org/1999/xhtml">
    <p>Test-Text</p>
</div>
</feed>
XML;
    $dom = new DOMDocument();
    $dom->loadXML($xml);
    $dom2 = new DOMDocument();
    $importedNode = $dom2->importNode($dom->documentElement, true);
    $dom2->appendChild($importedNode);
    $dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);$dom2->appendChild($importedNode);
}
test_document_import();
$execution_time = microtime(true) - $GLOBALS['_start_time'];
echo "Execution time: {$execution_time} seconds\n";
?>

Just curious )

I found the execution of DOM operations in JIT 1215 is relatively much slower (more than 100x times) than normal executions. Wondering if it is expected or not? If you lower down the optimization bit like 1211 or trigger bit 1205, the performance becomes reasonable.

To reproduce:

-d "zend_extension=/php-src/modules/opcache.so" -d "opcache.enable=1" -d "opcache.enable_cli=1" -d "opcache.jit=1215"

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions