Bug #80695 [NEW]: Extremely slow PHP file access operations on all Windows OS's

From: Date: Mon, 01 Feb 2021 19:54:25 +0000
Subject: Bug #80695 [NEW]: Extremely slow PHP file access operations on all Windows OS's
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231874@lists.php.net to get a copy of this message
From: info at futurion dot si Operating system: Windows (All platforms) PHP version: 7.4.14 Package: *Directory/Filesystem functions Bug Type: Bug Bug description:Extremely slow PHP file access operations on all Windows OS's Description: ------------ I did some extensive tests on various PHP versions on windows and linux platforms. Long story short, it seems windows suffer big time from slow file-access with all PHP file-related functions. I used as a sample a simple PHP script, which is published here: https://pastebin.com/VfLCgs3K That script takes about 10x or more time on windows in comparison to linux. I tried all possible combinations (power profiles, opcache, safe mode, windows defender and firewall disable, wincache, etc.), but it doesn't matter, nothing helps. I also tried different windows versions, different web servers, also running that script in CLI is slow as well. That above being said, would you be maybe kind enough to look into this issue, or maybe try running that same script at your side as well and maybe write something useful back. Is there actually any way to gain some "speed" on windows to be at least close to linux's performance? I really can't believe PHP on windows is so much slower than on linux. Kind regards and thank you in advance for your answer. Tomaz Kavcic. Test script: --------------- <?php $microtime = microtime(true); function displayCounter($txt){ global $microtime; echo "<p> {$txt}: ". round((microtime(true) - $microtime) * 1000,0) ."ms</p>"; $microtime = microtime(true); } $file_prefix = __DIR__ . '/file'; for($i= 1; $i < 1000; $i++){ file_put_contents($file_prefix . $i, ''); } displayCounter('File Creation'); for($i= 1; $i < 1000; $i++){ file_exists($file_prefix . $i); } displayCounter('file_exists'); clearstatcache(); for($i= 1; $i < 1000; $i++){ file_exists($file_prefix . $i); } displayCounter('file_exists (after cache clear)'); for($i= 1; $i < 1000; $i++){ unlink($file_prefix . $i); } displayCounter('unlink'); Expected result: ---------------- Tested on Ubuntu Linux 20.04 (Apache 2) - File Creation: 33ms file_exists: 4ms file_exists (after cache clear): 4ms unlink: 22ms Teset on Ubuntu Linux 20.04 (PHP CLI) - File Creation: 20ms file_exists: 2ms file_exists (after cache clear): 2ms unlink: 11ms Actual result: -------------- Tested on Windows 2019 Server (Also on other Windows OS's - similar results) - File Creation: 104ms file_exists: 21ms file_exists (after cache clear): 20ms unlink: 62ms -- Edit bug report at https://bugs.php.net/bug.php?id=80695&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80695&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80695&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80695&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80695&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80695&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80695&r=support Expected behavior: https://bugs.php.net/fix.php?id=80695&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80695&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80695&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80695&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80695&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80695&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80695&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80695&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80695&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80695&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80695&r=mysqlcfg

« previous php.bugs (#231874) next »