Audit usages of cache.static

Created on 28 November 2018, about 6 years ago
Updated 16 November 2023, about 1 year ago

Problem/Motivation

During performance auditing and testing in jsonapi module's issue #3014232: [regression] ResourceTypeRepository is significantly slower in JSON:API 2, becomes noticeable when handling hundreds of interlinked resources it turned out that the cache service cache.static is much slower than using native PHP private variables. mainly caused by the internal serialize on cache set and unserialize on EVERY cache get. In that particular issue the speed-up was around 60% of total request time. and the actual slow method that this was happening from 6 seconds to 30 mili-seconds. (around 200 times).

It turned out that the internal implementation used for static caches namly the cache.static service is \Drupal\Core\Cache\MemoryBackend and it's MUCH slower than the other available one \Drupal\Core\Cache\MemoryCache\MemoryCache

Proposed resolution

Change the factory and use the faster memory cache implementation internally by default or introduce a new service that could utilize that as easy as the cache.static, but to use the faster implementation.

Remaining tasks

Discussion, patch etc.

User interface changes

None expected - tweaks in cache internals.

API changes

TBD.

Data model changes

None expected (cache tweaks).

Release notes snippet

TBD.

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Cache 

Last updated 3 days ago

Created by

🇧🇬Bulgaria ndobromirov

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024