Skip to content

Optimize DOM property access#15626

Merged
ndossche merged 1 commit into
php:masterfrom
ndossche:dom-speedup-prop-access
Aug 29, 2024
Merged

Optimize DOM property access#15626
ndossche merged 1 commit into
php:masterfrom
ndossche:dom-speedup-prop-access

Conversation

@ndossche
Copy link
Copy Markdown
Member

For the read and write implementation, store the handler pointer in the first cache slot.
For the write implementation, use the second cache slot to store the property info.

For a micro-benchmark that performs a write:

$dom = new DOMDocument;
for ($i=0;$i<9999999;$i++)
        $dom->strictErrorChecking = false;

I obtain the following results on an i7-4790:

  ./sapi/cli/php ./write.php ran
    1.42 ± 0.08 times faster than ./sapi/cli/php_old ./write.php

For a micro-benchmark that performs a read:

$dom = new DOMDocument;
for ($i=0;$i<9999999;$i++)
        $dom->strictErrorChecking;

I obtain the following results on the same machine:

  ./sapi/cli/php ./read.php ran
    1.29 ± 0.13 times faster than ./sapi/cli/php_old ./read.php

For the read and write implementation, store the handler pointer in the
first cache slot.
For the write implementation, use the second cache slot to store the
property info.

For a micro-benchmark that performs a write:
```php
$dom = new DOMDocument;
for ($i=0;$i<9999999;$i++)
        $dom->strictErrorChecking = false;
```

I obtain the following results on an i7-4790:

```
  ./sapi/cli/php ./write.php ran
    1.42 ± 0.08 times faster than ./sapi/cli/php_old ./write.php
```

For a micro-benchmark that performs a read:
```php
$dom = new DOMDocument;
for ($i=0;$i<9999999;$i++)
        $dom->strictErrorChecking;
```

I obtain the following results on the same machine:

```
  ./sapi/cli/php ./read.php ran
    1.29 ± 0.13 times faster than ./sapi/cli/php_old ./read.php
```
Copy link
Copy Markdown
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSTM

@ndossche ndossche merged commit 367f303 into php:master Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants