Skip to content
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

Symfony is very slow in dev mode #509

Closed
Saintchicky opened this issue Nov 18, 2023 · 7 comments
Closed

Symfony is very slow in dev mode #509

Saintchicky opened this issue Nov 18, 2023 · 7 comments
Labels
support Support requested

Comments

@Saintchicky
Copy link

Hello everyone!
I am stuck when I uncomment the line - /app/vendor to improve Symfony's performance under Windows.
In the php container logs, I have this:
Fatal error: Uncaught LogicException: Symfony Runtime is missing. Try running "composer require symfony/runtime". in /app/bin/console:8
Indeed, we remove it from the bind mount, but then, I can't find the next step.
Thank you for your help!

@dunglas
Copy link
Owner

dunglas commented Nov 18, 2023

Can you install the missing package?

@Saintchicky
Copy link
Author

Saintchicky commented Nov 18, 2023

Thank you for responding.
I do have my vendor installed with the runtime dependency.
If I don't uncomment the line - /app/vendor, the project works but it's very slow (the home page, which doesn't have any database queries, just a small jpg image: 19404ms, and when I refresh it's 9800ms by the Symfony Profiler)
An additional piece of information, I don't have composer and php installed on my computer.
I have installed Turbo, and when I do a scroll, it takes between 10000ms and 9000ms if i hit another page with data's queries.
https://symfonycasts.com/screencast/symfony-doctrine/forever-scroll

@maxhelias maxhelias added the support Support requested label Dec 3, 2023
@jurchiks
Copy link

jurchiks commented Dec 4, 2023

This is a Windows issue, unfortunately. For some reason, it seems that, if you have the vendor folder mounted in the volume (which is what happens if /app/vendor is commented out - it is included in the /app mount, uncommenting it excludes it), instead of reading the dependency files from the container, which it should be doing, it seems to read them from the host filesystem, and that introduces way too much latency. That's really the only explanation that makes sense to me, but maybe it's something else. Either way, it sucks.

I "solved" it by leaving the /app/vendor folder commented out on first build so that it syncs the container with the host filesystem, then uncommenting it and make down && make up. This makes the whole thing way faster, but the obvious downside is that it now doesn't sync dependencies if you update them in the container, and you also constantly have one changed line in compose.override.yaml that you shouldn't commit. To sync dependencies, you have to comment the line, make down && make up, then uncomment the line and again make down && make up.

I really wish it wasn't this obnoxious to deal with, but I have not found an easier solution, and I tried for way too long.

Realistically what we would all want is that the /app/vendor folder is only synced one way: container -> host, and is never read from host (it should never be edited anyway), because when you build the image, it already downloads the dependencies in the image, it doesn't take them from the host, the only thing that does that is the volume mount.

@ili101
Copy link

ili101 commented Dec 4, 2023

Realistically what we would all want is that the /app/vendor folder is only synced one way: container -> host

@jurchiks I have a question because I work differently (with devcontainer). what is the point of having the vendor folder on the host and using Docker?
If you have already installed all the dependencies to run the project locally why do you also use Docker locally?

Also, I'm not familiar with Mac but on Windows, if you put your project folder in your WSL Ubuntu partition, mounting or not mounting the folder to Docker should have a similar performance.

@jurchiks
Copy link

jurchiks commented Dec 5, 2023

@ili101 I haven't tried putting the folder in WSL, guess I should try that. I read about it but somehow forgot...

As for devcontainer - I tried setting that up, but PHPStorm didn't (or maybe stll doesn't) support devcontainers, and I need the vendor folder for the code analyzer, otherwise everything's red. The dumb thing still has no support for just reading the vendor folder contents from the container like VS Code does, afaik.

@ili101
Copy link

ili101 commented Dec 6, 2023

@ili101 I haven't tried putting the folder in WSL, guess I should try that. I read about it but somehow forgot...

As for devcontainer - I tried setting that up, but PHPStorm didn't (or maybe stll doesn't) support devcontainers, and I need the vendor folder for the code analyzer, otherwise everything's red. The dumb thing still has no support for just reading the vendor folder contents from the container like VS Code does, afaik.

I made a fork with Devcontainer #523. works nicely with VSCode.
I don't use PhpStorm but I see that they added support for Devcontainer but it doesn't work for me, probably because of alpine support

@maxhelias
Copy link
Collaborator

The performance problems are not linked to this project but to the management of the Docker flysystem on the different OS, which are very different.
Window is known for having the worst performance and we can't do anything about it on our own.
Thank you for your understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Support requested
Projects
None yet
Development

No branches or pull requests

5 participants