Problem/Motivation
From the DrupalCon Barcelona Hard Problems Meeting on performance:
- ImageStyle/derivative stuff aggregate generation - remove state gets, file_exists(), cold cache memory/cpu
- Cron subscriber: state get/config get on EVERY request, we can only get rid of the config get by moving it into a module; we’ll still need a config get, but then you can at least avoid the config get if you uninstall that module https://www.drupal.org/node/2507031
- Alex: can’t we cache that?
- Berdir: No, wasn’t able to do so even after 6 months of trying. I used a cache collector, but that didn’t work out.
- Patch: https://www.drupal.org/node/2575105
Proposed resolution
The state service / \Drupal\Core\State\State extends \Drupal\Core\Cache\CacheCollector. This results in less queries to the database as a single cache entry stores commonly accessed state items.
Most code will not need to make any changes.
NOTE: due to a mistake proper discussion of the issue takes place in #2 -> #35 and #65 and after.
Remaining tasks
None.
User interface changes
None.
API changes
\Drupal\Core\State\State::__construct now requires a cache backend and the lock service to be injected. Support for calling this without those services is removed in Drupal 10.
Data model changes
None.
Release notes snippet
I don't think this is necessary.