Zend certified PHP/Magento developer

Progress with preloading

I’ve been doing some testing with preloading over the past two months, and figure I’d share a small update on my experience with it so far. It may be of help for some people?

I’m a Laravel developer so my testcase has been trying to preload the Laravel framework as well as my own application code. Starting with PHP 7.4 RC builds, I ran into some segfaults. I did some debugging and submitted a bug report, and Nikita has been very patiently helping me out! https://bugs.php.net/bug.php?id=78918

I’m happy to say that, as of PHP 7.4.2 (which is not released yet), all segfaults have been fixed and I was able to get preloading to work, but still ran into some issues:

  • First there were some unknown constants within Carbon, causing my preload script to crash. Thankfully these issues have been fixed and will be released in carbon:2.29.0. Carbon is a built-in dependency of Laravel and also used in lots of other projects, so it’s good to see this fixed before the release of PHP 7.4.2
  • Next I ran into some issues with nette/di, which registered class aliases unconditionally, causing PHP to throw runtime warnings. nette/di is a dependency on phpstan, which is why I had it loaded in my project. There was a kind of heated discussion (https://github.com/nette/di/issues/226) about this with the nette maintainer, and I’m still not sure whether the fix works or not. I simply removed phpstan to test my preload script ¯(ツ)/¯ people who are using nette/di as a core dependency should probably do some testing on their own and report back to David.
  • Finally, this is the preload script I’ve been using to test some things out: https://github.com/brendt/aggregate.stitcher.io/blob/master/preload.php. You can write your own very simply though: just make sure to require all files and their dependencies that you want preloaded.

I haven’t actually done proper benchmarks with preloading on, but I’ll do that next!

submitted by /u/brendt_gd
[link] [comments]