php-src/ext
Niels Dossche 6c0578d31c
Improve performance of urldecode() and rawurldecode()
There are two hot spots on my machines:
1. We copy the string because the internal PHP API works in-place.
2. The conversion of hex characters is slow due to going through the C
   locale handling.

This patch resolves the first hot spots by introducing 2 new internal
APIs that avoid the redundant copy and allocate an empty string upfront.
The second hotspot is resolved by having a specialised htoi handler.

For the following benchmark:
```php
$encoded = "Hello%20World%21+This%20is%20a%20test%3A%20%40%23%24%25%5E%26*%28%29";
for ($i=0;$i<2000000;$i++) {
  rawurldecode($encoded);
  urldecode($encoded);
}
```

On an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
  Time (mean ± σ):     364.8 ms ±   3.7 ms    [User: 359.9 ms, System: 3.3 ms]
  Range (min … max):   359.9 ms … 372.0 ms    10 runs

Benchmark 2: ./sapi/cli/php_old x.php
  Time (mean ± σ):     565.5 ms ±   4.9 ms    [User: 561.8 ms, System: 2.5 ms]
  Range (min … max):   560.7 ms … 578.2 ms    10 runs

Summary
  ./sapi/cli/php x.php ran
    1.55 ± 0.02 times faster than ./sapi/cli/php_old x.php
```

On an i7-1185G7:
```
Benchmark 1: ./sapi/cli/php x.php
  Time (mean ± σ):     708.8 ms ±   6.1 ms    [User: 701.4 ms, System: 6.3 ms]
  Range (min … max):   701.9 ms … 722.3 ms    10 runs

Benchmark 2: ./sapi/cli/php_old x.php
  Time (mean ± σ):      1.311 s ±  0.019 s    [User: 1.300 s, System: 0.008 s]
  Range (min … max):    1.281 s …  1.348 s    10 runs

Summary
  ./sapi/cli/php x.php ran
    1.85 ± 0.03 times faster than ./sapi/cli/php_old x.php
```

Closes GH-18378.
2025-04-24 22:14:55 +02:00
..
bcmath ext/bcmath: Use const qualifiers appropriately (#18284) 2025-04-11 12:39:31 +09:00
bz2 streams: Indicate which argument fails the stream ZPP check 2025-03-24 22:54:34 +00:00
calendar ext/calendar: array optimisations. (#18388) 2025-04-21 20:49:21 +01:00
com_dotnet
ctype
curl ext/curl: curl_getinfo, curl_multi_get_handles and curl_multi_setopt array optimisations. (#18389) 2025-04-21 17:13:57 +01:00
date Merge branch 'PHP-8.4' 2025-04-22 17:11:32 +01:00
dba Merge branch 'PHP-8.4' 2025-04-05 18:33:12 +01:00
dl_test Merge branch 'PHP-8.4' 2025-03-14 10:51:50 +01:00
dom Merge branch 'PHP-8.4' 2025-04-23 18:30:05 +02:00
enchant ext/enchant: Remove useless char* casts 2025-03-25 06:59:57 +00:00
exif Add OffsetTime* Exif tags 2025-04-07 18:47:06 +02:00
ffi ext/ffi: Add comment about why a function was manually optimized 2025-03-31 17:03:48 +01:00
fileinfo Merge branch 'PHP-8.4' 2025-04-24 11:28:47 +02:00
filter Merge branch 'PHP-8.4' 2025-04-11 23:36:42 +02:00
ftp ext/ftp: Remove output field of ftpbuf_t struct 2025-04-03 22:47:13 +01:00
gd ext/gd: array supplied to user optimisations. (#18366) 2025-04-20 17:30:12 +01:00
gettext
gmp Don't evaluate GMP comparison multiple times (#18321) 2025-04-14 11:19:14 +02:00
hash ext/hash: Use new php_streams fast ZPP specifier 2025-03-03 18:08:23 +00:00
iconv ext/iconv: Use RETURN_BOOL() instead of if/else 2025-04-14 10:15:55 +01:00
intl backporting C++17 detection support for recent icu4c releases. 2025-04-23 11:01:11 +02:00
json Merge branch 'PHP-8.4' 2025-03-08 12:27:56 +01:00
ldap Merge branch 'PHP-8.4' 2025-04-16 11:41:33 +02:00
libxml Merge branch 'PHP-8.4' 2025-04-07 13:01:52 +01:00
mbstring Remove unused strcasecmp definition (#17050) 2025-03-21 18:30:22 +01:00
mysqli Merge branch 'PHP-8.4' 2025-03-16 14:26:38 +01:00
mysqlnd Drop unused variables (#18023) 2025-04-19 13:26:09 +01:00
odbc
opcache Merge branch 'PHP-8.4' 2025-04-21 13:15:50 +02:00
openssl Merge branch 'PHP-8.4' 2025-04-11 21:04:24 +02:00
pcntl ext/pcntl: pcntl_sigprocmask/pcntl_getcpuaffinity to packed arrays. (#18369) 2025-04-20 23:23:56 +01:00
pcre Remove PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK from pcre compile options 2025-03-31 20:01:45 +02:00
pdo Merge branch 'PHP-8.4' 2025-04-11 23:36:42 +02:00
pdo_dblib
pdo_firebird Merge branch 'PHP-8.4' 2025-04-19 14:11:35 +09:00
pdo_mysql
pdo_odbc
pdo_pgsql ext/pdo_pgsql: updating copy from according to pgsql extension workflow. (#18175) 2025-03-28 18:24:45 +00:00
pdo_sqlite Implement GH-17321: Add setAuthorizer to Pdo\Sqlite (#17905) 2025-04-18 00:34:46 +02:00
pgsql Merge branch 'PHP-8.4' 2025-04-21 17:47:55 +02:00
phar
posix ext/posix: preallocate arrays and/or change to packed ones. (#18370) 2025-04-20 23:23:43 +01:00
random
readline
reflection Zend: Add MUTABLE zend_type foreach macros and const qualifiers 2025-04-07 12:52:40 +01:00
session [skip ci] Remove wrappers comments in session ext (#18017) 2025-03-13 12:14:31 +00:00
shmop
simplexml Merge branch 'PHP-8.4' 2025-04-11 23:57:03 +02:00
skeleton
snmp Merge branch 'PHP-8.4' 2025-04-11 23:36:42 +02:00
soap Merge branch 'PHP-8.4' 2025-03-21 08:26:04 +01:00
sockets ext/sockets: using array optimisations. (#18367) 2025-04-20 19:34:11 +01:00
sodium
spl Merge branch 'PHP-8.4' 2025-04-14 14:11:40 +02:00
sqlite3 ext/sqlite3: querySingle amd fetchArray methods optimisations. (#18385) 2025-04-21 16:37:34 +01:00
standard Improve performance of urldecode() and rawurldecode() 2025-04-24 22:14:55 +02:00
sysvmsg
sysvsem
sysvshm
tidy ext/tidy: array optimisations, children node arrays as packed. (#18375) 2025-04-21 13:47:53 +01:00
tokenizer Add (void) cast 2025-03-24 19:35:30 +01:00
xml Merge branch 'PHP-8.4' 2025-04-23 22:10:13 +02:00
xmlreader Merge branch 'PHP-8.4' 2025-04-11 23:36:42 +02:00
xmlwriter ext/standard/file: clarify fclose() warning 2025-03-24 22:54:34 +00:00
xsl Merge branch 'PHP-8.4' 2025-02-22 16:00:45 +01:00
zend_test ext/standard: Remove #[\NoDiscard] from flock() (#18255) 2025-04-08 14:23:03 +02:00
zip Merge branch 'PHP-8.4' 2025-04-16 10:46:23 +02:00
zlib ext/zlib: gzfile() files list as packed array (#18380) 2025-04-21 14:47:52 +01:00
ext_skel.php