Review main Merged

62558[TASK] Streamline usage of caching framework

Helmut Hummel CR +2 V +2 Hard +102 −212 updated 02/14/20, 19:42

Commit message

Use code cache properly instead of storing strings into it,
because it is proper usage of our API, removes the need
for stripping PHP code strings and improves performance
when OPCache is in use (which is recommended on production systems).

Additionally all calls to ->has are removed, except one place where
boolean values are stored in a runtime cache and in tests,
because the API guarantees returning "false" when using ->get or ->require

Doing so reduces the amount of lookups on the backend storage (file_exists
for file backend, SQL queries for DB backend) and makes up more
straightforward code in most places (reduces cyclomatic complexity by removing obsolete "else" branching).

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Achim Fritz +1
  • Verified V +2 Done
    • Benni Mack +2
    • Achim Fritz +1
    • TYPO3com +1 CI

Issues 1

Files 21

Show 1 more file

Review log 1622

  1. Helmut Hummel uploaded patch set 1 12/06/19, 12:55

  2. TYPO3com voted on patch set 1 V -1 12/06/19, 12:55 Completed build in 20s on Fri, 6 Dec, 12:55 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39155

  3. Mathias Brodala commented on patch set 1 12/06/19, 13:50

    SiteConfiguration.php:150

    This is barely readable IMO. I also wonder if we could incorporate the NullBackend here to make the code even easier to read.

    SiteConfiguration.php:270

    Why this change? It's not necessary AFAIS and is not really true since CacheManager::getCache() definitely returns FrontendInterface.

    ReferenceIndex.php:232

    Same here; with a NullBackend this could be simplified a lot.
  4. Helmut Hummel commented on patch set 1 12/07/19, 20:03

    SiteConfiguration.php:150 Reply

    Conditions or ternary operators is indeed a matter of preference. I could easily re-write this as if condition. I personally find the one-liner pretty readable though. Passing in a frontend, which has a null backend here is a refactoring that might make sense, but isn't related at all to this change (and the details when trying so, will likely be ugly as well). In any case, this isn't in the scope of this change.

    SiteConfiguration.php:270 Reply Unresolved

    Well, even before the code using this cache relied on the fact it being a PhpFrontend. Type hinting the interface has always hidden this dependency. In fact, the code in all places in TYPO3 would fail if the core cache isn't a PhpFrontend. I find it useful to make this fact explicit.

    ReferenceIndex.php:232 Reply

    Might be, nontheless not in the scope of this change
  5. Helmut Hummel uploaded patch set 2 12/07/19, 20:03

  6. Helmut Hummel uploaded patch set 3 12/07/19, 20:08

  7. Helmut Hummel commented on patch set 3 12/07/19, 20:09

    SiteConfiguration.php:150 Reply

    I removed the obsolete assignment though :)
  8. Helmut Hummel commented on patch set 3 12/07/19, 20:10

    ReferenceIndex.php:232 Reply

    should be done in a different change
  9. TYPO3com voted on patch set 2 V -1 12/07/19, 20:11 Completed build in 07m 40s on Sat, 7 Dec, 08:11 PM Test Summary: 4431 of 68613 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39249

  10. TYPO3com voted on patch set 3 V -1 12/07/19, 20:16 Completed build in 08m 36s on Sat, 7 Dec, 08:16 PM Test Summary: 3612 of 69158 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39250

  11. Alexander Schnitzler commented on patch set 3 12/08/19, 08:40

    Do you maybe have numbers for this change at hand? Maybe even a diff created with blackfire?
  12. Helmut Hummel commented on patch set 3 12/09/19, 08:58

    > Patch Set 3: > > Do you maybe have numbers for this change at hand? Maybe even a diff created with blackfire? The most beneficial change performance wise is to not decode data from core cache, but just require the cache file. I measured the performance benefit (when using opcache) here: https://forge.typo3.org/issues/82408 I would neglect the performance penalty when opcache is not enabled, because enabling it is recommended for production sites anyway.
  13. Helmut Hummel commented on patch set 3 12/09/19, 09:02

    > Patch Set 3: > > Do you maybe have numbers for this change at hand? Maybe even a diff created with blackfire? Regarding removing the ->has calls: This is rather a micro optimisation, which likely does not have a big impact, when not called in a loop. However it IMHO makes the code a bit more compact as well, so I don't see any negative effects for such change. In contrary, usage is now streamlined to be the same in all places
  14. TYPO3com commented on patch set 3 12/27/19, 20:04 Completed build in 0h 04m 57s on Fri, 27 Dec, 08:04 PM Test Summary: 3725 of 69158 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-39250

  15. Helmut Hummel uploaded patch set 4 02/14/20, 13:33

  16. TYPO3com voted on patch set 4 V -1 02/14/20, 13:47 Completed build in 13m 26s on Fri, 14 Feb, 01:47 PM Test Summary: 71227 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-75

  17. TYPO3com voted on patch set 4 V +1 02/14/20, 13:52 Completed build in 32m 04s on Fri, 14 Feb, 01:52 PM Test Summary: 71238 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-75

  18. Daniel Goerz commented on patch set 4 02/14/20, 15:32

    PackageManager.php:172

    Why do we remove the check here?
  19. Achim Fritz voted on patch set 4 V +1 CR +1 02/14/20, 17:27

  20. Benni Mack commented on patch set 4 02/14/20, 19:10

    PackageManager.php:172 Reply Unresolved

    It actually fixes a minor bug if you extend the packageManager but you want to update the package states cache externally
  21. Benni Mack voted on patch set 4 V +2 CR +2 02/14/20, 19:42

  22. Benni Mack merged patch set 5 02/14/20, 19:42