-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Huge performance degradation of ReflectionClassResource and FileResource on big projects inside Docker For Mac #25999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you measure any difference with that change? |
Please check out the attached picture. This is profiler's run result and we can see what both functions inside methods take time to execute. I use Docker For Mac Edge 18.02 and PHP 7.2.1 with php-fpm inside Docker's container. Docker For Mac have massive file system performance difference between container and host os. Without docker-sync container's hard disk works 100x time slower than host. I see huge difference between original and patched code. |
Can you double check that php's stats cache is working? (Note that I don't know exactly how to do that. Maybe by forcibly disabling it a see any diff?) |
Oh, can you also use eg Blackfire to profile the performance difference with your patch? A flammegraph is a statistical tool so it looses information. Maybe a more precise picture could help better understand the situation. |
Sorry, I cant you Blackfire locally. I have checked php' stats cache. It is working, call if http://php.net/manual/en/function.stat.php function returns meta data after file_exists call. Then the filemtime call is executed with full stat cache. I wil write synthetic test case on clear php later so you can check it on your system. |
Check the code from attached file please test.txt I run it on php-fpm (not cli) and this is my result:
As you see two calls file_exists + filemtime is 13x slower than one filemtime call. |
The call to stat() near file_exists() completely defeats the comparison, because stat() is the heaviest call. It cannot be used to check if the cache is warm or not. |
Ok, have you any idea how can i "double check that php's stats cache is working"? |
Second question -- if my configuration broken and stat cache not works are where other users with same issues? And one more -- is where any reason to make call to file_exists + filemtime if one can call only filemtime? |
I checked all several time -- the issue reproduces only on Docker For Mac native volume. If I start php server via docker-sync or read file not from shared Docker's volume but from internal directory -- where are very small difference between patcher and original code. But then I tried to check difference on Docker's volume I see huge performance degradation. It is famous issue with Docker For Mac FS, one of relative topic https://forums.docker.com/t/file-access-in-mounted-volumes-extremely-slow-cpu-bound/8076/169 Another clear test case with only one file -- test.txt My result:
Can you please remove file_exists call to increase symfony performance inside Docker For Mac containers? Our big project takes much time to check is container fresh on each request. |
Would you like to submit a PR? I think doing this on branch 2.7 would be possible (we'll then merge it into 3.4) |
I dont know what is PR mean. Can you explain how I can help you please? |
I've very interested in such improvement as well. I'd love to see your patch. |
Thank you for help. I cant work today any more and will send you pull request in several days. |
@nicolas-grekas, where is not way to patch 2.7. ReflectionClassResource class doesnt exist in that version. I made pull request to 3.4 #26013, can you check it please? |
…mifedorenko) This PR was merged into the 3.4 branch. Discussion ---------- [Config] Only using filemtime to check file freshness | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25999 | License | MIT Commits ------- 52c9cb4 [Config] Only using filemtime to check file freshness
Uh oh!
There was an error while loading. Please reload this page.
Hello.
ReflectionClassResource::isFresh and FileResource::isFresh methods have performance issue on huge projects and slow file system. For example I'm work with php project with about 22K source files in Docker For Mac.
Method isFresh can makes system call to file system twice for file_exists and filemtime but where are no need to make two calls. You can call only filemtime in all cases and check return value:
The text was updated successfully, but these errors were encountered: