laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

PHP 7.4 preloading and laravel #1406

Closed halaei closed 5 years ago

halaei commented 5 years ago

I am wondering if anyone has tried PHP 7.4 preloading (https://wiki.php.net/rfc/preload) with Laravel.

  1. Does everything works just fine or there is need for changes in the framework as well?
  2. What is the performance boost? Does it completely remove framework bootstrap time or some parts of the framework must run once per request, even-though they are logically request independent?
  3. How does it compare to other solutions to reduce boot time?
deleugpn commented 5 years ago

I'm trying to learn how to compile php and benchmark to check this.

halaei commented 5 years ago

It is only about compiling code and thinks related to that. So it is not going to cache the logic of bootstrapped frameworks into some variable that may be used later:

Static members and static variables

To avoid misunderstanding, it is clear stated that preloading doesn't change the behavior of static class members and static variables. Their values are not going to relive request boundary.

So it means other solutions (microframeworks, swoole, ...) are still going to be beneficial.

jhdxr commented 5 years ago

As the RFC stated

While storing files in an opcode cache eliminates the compilation overhead – there is still cost associated with fetching a file from the cache and into a specific request's context. We still have to check if the source file was modified, copy certain parts of classes and functions from the shared memory cache to the process memory, etc.

so yes, it doesn't change any existing logic, which is good, because it means we don't have to change a log, and PHP without preloading support (old PHP version, or opcache disabled) won't be affected, but it still can help the performance. Why not have a try?

taylorotwell commented 5 years ago

We will definitely do it.

fridzema commented 4 years ago

@taylorotwell Any updates on this? Seems there is no "right" way to this. All solutions from various blogs/tutorial seems a bit hacky.

amitkoth commented 4 years ago

Any update on your approach to this @taylorotwell ?

atapatel commented 4 years ago

Following this thread.