Problem/Motivation

In environment_indicator_get_active() there is:

  // 3. Check if the indicator is in the db cache.
  if ($cached_env = cache_get('environment_indicator')) {
    $env = $cached_env->data;
    return environment_indicator_alter_and_cache($env);
  }

environment_indicator_alter_and_cache() invokes the alterations of the EI and caches. In this case it means we grab a cache that should always have the alterations set and sets probably the same cache again.

Proposed resolution

Just don't use environment_indicator_alter_and_cache() in this case. Or do the alterations but not cache. I didn't check but imho the alteration and cache set should only be done if a form submit of the EI settings did flush the cache. So a cache get should be enough here.

Original report by Kars-T

Dear all

while profiling my site I stumbled upon a constant cache set by EI. I believe it is unnecessary. To remove it is rather easy and I provided a patch. But what I didn't look up is if the EI Cache is cleared on form submit of a preset. If yes this should work fine. If not the cache is basically never reset.

Cheers

Karsten

Comments

Kars-T created an issue. See original summary.

kars-t’s picture

Issue summary: View changes
vzblk’s picture

This issue leads to more performance issues further, for example if you use git release in EI then it calls 'git describe --all' for every page and I believe it is definitely unnecessary.

vzblk’s picture

Status: Active » Needs review
StatusFileSize
new955 bytes

Fixed unnecessary cache_set and added cache_clear_all on form submit

azinck’s picture

Status: Needs review » Reviewed & tested by the community

Came looking for this. It does seem crazy to ignore this cache. #4 RTBC

jigarius’s picture

Quite a pickle. I made a fix in my local and it improved performance to a considerable extent. I think the issue should be treated as an improvement suggestion instead of a feature request (if not a bug).

scottrigby’s picture

Category: Feature request » Bug report

@breft you are right, this actually qualifies as a bug. See Category settings of issues, specifically:

  • Memory leaks
  • Scalability issues

The caching fix in #4 by @vzblk has been running on the edit webs of a number of high-demand production sites for white a while now.

e0ipso’s picture

Thanks all. As you can see, it's taking me too long to fix issues that the community has already fixed.

I am currently looking for co-maintainers, so if you want to help me take good care of this module please drop me an email using the contact form.

I'll be merging this asap.

e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

Merged.

  • e0ipso committed db229b2 on 7.x-2.x authored by vzblk
    Issue #2557837 by Kars-T, vzblk: Do not always reset the cache by using...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.