Review main Abandoned

69369[FEATURE] Add a basic preload mechanism for PHP 7.4+.

crell CR 0 V 0 Normal +189 −0 updated 10/17/21, 20:38

Commit message

This includes a common set of classes to preload, plus a mechanism
for site-specific additions.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 1

Review log 1214

  1. crell uploaded patch set 1 06/02/21, 23:37

  2. core-ci voted on patch set 1 V -1 06/02/21, 23:39 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12139

  3. crell commented on patch set 1 06/02/21, 23:40

    The class list here I generated by sticking a print line into the autoloader and loading the home page. I haven't finished moving all of the files to class_exists() calls yet as I'm doing it manually right now, so I'd prefer to get some feedback bfore I go through that work. 😊 Also, I am unclear how to benchmark this most efficiently. Benchmarks from other projects for the benefits of preloading are all over the map, from 2-3% to 70% improvement.
  4. crell uploaded patch set 2 06/02/21, 23:51

  5. core-ci voted on patch set 2 V +1 06/02/21, 23:59 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/12140

  6. Christian Kuhn commented on patch set 2 06/03/21, 10:04

    Neat :) What will happen with this file in composer mode where typo3/sysext/* are packages? Other files like index.php, typo3/index.php and typo3/install.php have some composer hook to put them into public folder. I guess that't not what we want for this preload file, and still it should end up somewhere? There are classes from extensions that are not mandatory - for instance the adminpanel is optional. Performance-wise, I'd guess you can measure a benefit for full-cached FE requests - those should be below 10ms on casual systems, so that's where opcache warming kicks in most. I don't think there will be much measurable difference for FE calls that are not not cached (yet), and also not for pages calls that have USER_INT plugins: The sheer amount of db calls takes multiple orders of magnitude more time than php's class parsing. So, I wonder if it's worth optimizing towards this? Maybe simply optimize towards full-cached page accesses? This would reduce the list of to-warmup classes drastically, I guess?
  7. crell commented on patch set 2 06/03/21, 14:05

    Reply

    An excellent question. I made the path here to keep it out of the root, so that sites could have their own file there instead, and the include path is "this is what worked in ddev." We can easily move both around to wherever makes sense, I'm easy. Strange that admin panel was showing up in the list when I generated it by viewing the bootstrap home page. Why would that be? (Unless I got the lists mixed up...) I agree that warm-cache FE is the primary target, although I thought that's what I was getting with the list I generated. At least some classes from no-cache FE is probably wise to include as well. We can fiddle with the list however makes sense. One nice thing about preload is that it's essentially orthogonal to any other performance mechanisms, so it warms the opcode cache but doesn't interfere with application caching, HTTP caching, or DB-query-optimization.
  8. Benni Mack commented on patch set 2 06/13/21, 11:18

    Hmm, this sounds like a good job for a common, separate package like this https://github.com/TYPO3/class-alias-loader Basically: Every package provides a file (either configurable via composer.json or in a defined space) that defines all classes that would benefit from a preloading mechanism. A composer plugin, similar to class-alias-loader, then generates a full list as a preload.php file in the vendor folder on post-dump-autoload, which then just sits in the vendor folder and people can opt-in to enable pre-loading if they want to? Or even not use the additional package if they want a custom implementation? Another approach is this one: https://github.com/symfony/symfony/pull/36103
  9. crell commented on patch set 2 06/18/21, 19:29

  10. Helmut Hummel commented on patch set 2 06/20/21, 15:11

    Thanks for looking into this topic. I fear though that this approach is a bit too basic, leading to it not working properly for Composer based installations. Rather than providing a single hard coded list of classes, I'd suggest to do a bit more to allow every extension (including core extensions) to provide a list of classes to be preloaded, which is then used to generate the preload file (similar to Symfony's approach

    preload.php:34 Unresolved

    In Composer mode, the autoload file won't we available in that location. In fact, it isn't possible to hard code the location of that file, as it might be in different locations depending on configuration in root composer.json
  11. crell commented on patch set 2 06/21/21, 14:53

    Reply

    Please see the linked discussion thread on Decisions. There's additional context and questions there, so let's keep the discussion in one place.
  12. Christian Kuhn commented on patch set 2 10/17/21, 20:36

    that's a draft. should we maybe abondon the patch until more active work is committed to it?
  13. Christian Kuhn commented on patch set 2 10/17/21, 20:38

    actually, i hope that's fine: i'll abandon for now. feel free to pick up again.
  14. Christian Kuhn abandoned the change 10/17/21, 20:38