[GIT-PULLS] [php-src] PR #22722: perf: direct syscall fastpath for absolute paths in zend_virtual_cwd
[email protected] (henderkes)
| Newsgroups | php.git-pulls |
|---|---|
| Message-ID | <EAEg9X1J5gjlrKzjD5iQM8pPeyQyi35Fv40cVjWwLqA@main.internal.php.net> |
Pull Request: https://github.com/php/php-src/pull/22722
Author: henderkes
Absolute paths don't need to go through the per-thread cwd emulation, add a fast-path to directly hand them to libc.
since relative paths won't start with a leading slash, this adds negligible cost for them
```php
<?php
chdir(__DIR__);
$s = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
file_exists("data.txt");
}
$rel = microtime(true) - $s;
$abs = __DIR__ . "/data.txt";
$s = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
file_exists($abs);
}
$abs_t = microtime(true) - $s;
```
| workload | master | patch | delta |
|---|---|---|---|
| relative path | 0.3521s | 0.3524s | +0.09% |
| absolute path | 0.3162s | 0.2623s | −17.05% |