Skip to content

Excessive loading of zend locale information from Cache #20973

@tim-reynolds-visionet

Description

@tim-reynolds-visionet

While investigating performance issues we became aware that our server was making hundreds of requests to our cache backend (Redis) for static locale information that would not change.

An example cache key is: 35e_Zend_LocaleC_en_BE_currencynumber_

Essentially anything with Zend_Locale should never change for the given key within a single run, yet to us it seems it is hitting the cache every time the data is needed.

Example:
magento/zendframework1/library/Zend/Currency.php method _checkParams calls
Zend_Locale_Data::getContent which, if caching is on (how do we disable?) loads the currency to region value from the cache. It does not save it in any type of local cache though. And it seems to get this info every time we call formatCurrency. Even if we turned the cache off, it would be re-loading this from disk every single call. This seems very inefficient.

On some of our larger pages we found it was loading from a few specific keys hundreds of times.

Steps to reproduce (*)

  1. Add the following code to the 'load' method of your chosen cache backend at the beginning of the method:
    if(!isset($_SERVER['cache_counter'][$id])){$_SERVER['cache_counter'][$id] = 0;}
    $_SERVER['cache_counter'][$id]++;
    asort($_SERVER['cache_counter']);
  2. Add a breakpoint at the end of the execution of index.php, and inspect the $_SERVER['cache_counter'] variable to see how many times each ID was requested from cache. You should see that Zend_Locale dominates with repeated calls.

Expected result (*)

  1. Static information that will never change in the course of a page load should not be requested more than once.

Actual result (*)

  1. Static information that should not be requested more than once is requested many many times.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions