You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimize DOM HTML serialization for UTF-8 (#16376)
* Use a direct call for decoding the UTF-8 buffer
* Add fast path for UTF-8 HTML serialization
This patch adds a fast path to the HTML serialization encoding that has
to encode to UTF-8. Because the DOM internally represents all strings
using UTF-8, we only need to validate here.
Tested on Uncyclopedia English home page on an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 516.0 ms ± 6.4 ms [User: 511.2 ms, System: 3.5 ms]
Range (min … max): 506.0 ms … 527.1 ms 10 runs
Benchmark 2: ./sapi/cli/php_old x.php
Time (mean ± σ): 682.8 ms ± 6.5 ms [User: 676.8 ms, System: 3.8 ms]
Range (min … max): 675.8 ms … 695.6 ms 10 runs
Summary
./sapi/cli/php x.php ran
1.32 ± 0.02 times faster than ./sapi/cli/php_old x.php
```
(And if you're interested: it takes over a second on my machine using the old DOMDocument class)
Future optimizations are certainly possible, but let's start here.
0 commit comments