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 skeleton makes usage of opcache.preload impossible #35759

Closed
Nemo64 opened this issue Feb 17, 2020 · 3 comments
Closed

Symfony skeleton makes usage of opcache.preload impossible #35759

Nemo64 opened this issue Feb 17, 2020 · 3 comments

Comments

@Nemo64
Copy link
Contributor

Nemo64 commented Feb 17, 2020

Symfony version(s) affected: v4.4.4 v5.0.4

Description
I tried to use the preload feature.
Symfony generates a .preload.php Kernel during cache warmup for PHP 7.4's opcache.preload. Except when actually are using PHP 7.4, then this file is not generated.

I traced it to the point that the parameter container.dumper.inline_class_loader needs to be true in order for the file to be generated. However, the current symfony skeleton (composer create-project symfony/website-skeleton my_project_name) includes this statement in the kernel: $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); which disables that feature when you are running PHP 7.4 (unless debug is enabled which it isn't in prod).

How to reproduce
composer create-project symfony/website-skeleton my_project_name
cd my_project_name
bin/console cache:clear -e prod
Then a srcApp_KernelProdContainer.preload.php should be there, but it isn't.
Do the same with PHP 7.3 and it works perfectly... even though it is useless as php 7.3 can't use that file.

Possible Solution
The simplest solution is to remove the condition \PHP_VERSION_ID < 70400 but there is probably a reason for that feature to be disabled in php 7.4.

Another would be to modify the the PhpDumper to generate the file even though the inline_class_loader is disabled.

I also think it is a bug that the file isn't garanteed to be there as a server expecting this file will fail to start php processes. It would be better to have an empty file than to have nothing.

Additional context
I hardcoded container.dumper.inline_class_loader to true to get the preload file to test that feature and noticed that my small application became ever so slightly slower (~15ms to ~18ms in my example form request).

@OskarStark
Copy link
Contributor

@nicolas-grekas as far as I know this feature is not yet really production ready from the php side, right?

But what about the condition with below 7.4? Is this a mistake?

@greedyivan
Copy link
Contributor

It comes from this: #34368
It did not work on PHP 7.4.0 RC6 correctly, so it was disabled.

@guilliamxavier
Copy link
Contributor

This seems fixed in v4.4.6+ / v5.0.6+ thanks to #36103, isn't it?

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

No branches or pull requests

7 participants