Review main Merged

61078[BUGFIX] Speed up SiteConfiguration loading

Benni Mack CR +2 V +2 Normal +61 −22 updated 06/19/19, 11:20

Commit message

Profiling shows that when linking to 100
pages, SiteFinder (which instantiates SiteConfiguration)
is instantiated 100 times. Although SiteFinder information
might change during one request, the SiteConfiguration
does not (except when updating the Configuration via API).

So, a first-level-cache can be used to avoid calls
to "cache_core" multiple times during one request,
and SiteConfiguration can become a Singleton instance.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
    • Daniel Goerz +1
  • Verified V +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
    • Daniel Goerz +1
    • TYPO3com +1 CI

Issues 1

Files 4

Review log 1518

  1. Benni Mack uploaded patch set 1 06/17/19, 19:39

  2. TYPO3com voted on patch set 1 V -1 06/17/19, 19:52 Completed build in 13m 14s on Mon, 17 Jun, 09:52 PM Test Summary: 929 of 46793 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34403

  3. Benjamin Franzke uploaded patch set 2 06/17/19, 21:00

  4. Benjamin Franzke commented on patch set 1 06/17/19, 21:00

    SiteConfiguration.php:71 Unresolved

    strictly seen non nullable constructor parameters are forbidden for SingletonInterface's (currently). We could move the usual instructor `Environment::getConfigPath() . '/sites'` – but i'm not sure what the reasoning was to provide that to be configurable. Anyway, as we want move to DI, I think it's fine to keep this parameter, as strictly required configuration parameters will actually become a good pattern once we have DI configuration.

    SiteConfiguration.php:81 Unresolved

    Not sure if you agree, but we could use a null coalescing operator here, which is supposed to be even faster. (DI implementations use that to get/create cache entries as well, and performance analysis showed that ?? brings improvements). I will prepare that in a new patchset. I'm curious whether your profiling shows any differences with patchset 2 applied.
  5. Benjamin Franzke voted on patch set 2 V +1 CR +1 06/17/19, 21:01

  6. TYPO3com voted on patch set 2 V +1 06/17/19, 21:17 Completed build in 17m 10s on Mon, 17 Jun, 11:17 PM Test Summary: 46440 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34404

  7. Benni Mack commented on patch set 2 06/18/19, 05:10

    SiteConfiguration.php:89

    that's technically breaking, however I don't know how many people rely on calling resolveAllExistingSites(), maybe we should just keep the resolveAllExistingSites public
  8. Benni Mack commented on patch set 2 06/18/19, 05:10

    I think we should also make this possible in v9 btw...
  9. Benjamin Franzke commented on patch set 2 06/18/19, 06:37

    SiteConfiguration.php:89 Reply Unresolved

    Yup, I also thought about that, but as SiteConfiguration class is marked @internal, I thought this would be fine here. BUT: due to your v9 backport thouhts, I understand that this may become frustrating for people that use this class despite being @internal – they may say "It would have been easy to stay non-breaking here". So let's got with public if we intend to backport this patch.
  10. Benjamin Franzke uploaded patch set 3 06/18/19, 06:57

  11. Benjamin Franzke voted on patch set 3 V +1 CR +1 06/18/19, 06:58

  12. Jonas Eberle commented on patch set 3 06/18/19, 07:08

    SiteConfiguration.php:65

    I suggest $existingSitesCache or similar for readability.
  13. TYPO3com voted on patch set 3 V +1 06/18/19, 07:12 Completed build in 14m 20s on Tue, 18 Jun, 09:12 AM Test Summary: 46442 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-34408

  14. Benjamin Franzke commented on patch set 3 06/18/19, 07:23

    SiteConfiguration.php:65 Reply Unresolved

    I also thought about another name (e.g. $resolvedSites), but I think $firstLevelCache is the best one in this case: * It becomes very clear, that this cache is intended for performance reasons, which means the someone anlyzing this with memory usage in mind will not be tempted to go over this and say: lets save some memory here and remove this) * This class has pretty much only one task and the generic variable identifier is fine in that case IMO. * We actually have two caches here, where $firstLevelCache is more descriptive than $existingSitesCache – that means we would need $resolvedSitesFirstLevelCache here. As that sucks, let's stick with $firstLevelCache.
  15. Daniel Goerz voted on patch set 3 CR +1 06/18/19, 14:49

  16. Daniel Goerz voted on patch set 3 V +1 06/19/19, 10:58

  17. Benni Mack commented on patch set 3 V +2 CR +2 06/19/19, 11:20

    Checked with Jonas. All good. Let's continue
  18. Benni Mack merged patch set 4 06/19/19, 11:20