Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(dev/core#284) System::flushCache - Reproduce legacy cache behavior. Improve test performance. #12590

Merged
merged 1 commit into from
Jul 29, 2018

Conversation

totten
Copy link
Member

@totten totten commented Jul 28, 2018

Overview

CRM_Utils_System::flushCache() calls CRM_Utils_Cache::singleton()->flush(). The significance of this changed during development of 5.4.alpha. With an aim to being conservative and reproducing old behavior, I previously patched 5.4.alpha to add several extra flushes. However, it wasn't really as
conservative as hoped -- because the "old behavior" depended on the environment. This patch brings us closer the "old behavior".

See also: https://lab.civicrm.org/dev/core/issues/284

Before (Behavior in version <=5.3)

On systems with memory-backed caches, this had an aggressive cascading side-effect where several named caches (settings, etc) were also flushed.

On systems with a default configuration (SQL+ArrayCache), there was a very limited cascading effect -- it only cleared the in-process ArrayCache. The bulk of the cache content was preserved in SQL.

Before (Behavior in version ~= 5.4.alpha)

CRM_Utils_System::flushCache() calls CRM_Utils_Cache::singleton()->flush().

To simulate the cascading effect, flushCache() explicitly flushes a half-dozen individual caches. (These half-dozen are chosen to match the old cascade list and exclude some new things which would problematic.)

On systems with memory-backed caches, this reproduces the aggressive cascading effect.

On systems with with a default configuration (SQL+ArrayCache), this amplifies the flushing -- because it also destroys the underlying SQL caches.

This has the side-effect of significantly degrading performance of the test suite.

After (Behavior with patch)

CRM_Utils_System::flushCache calls CRM_Utils_Cache::singleton()->flush().

To simulate the cascading effect, flushCache() explicitly flushes a half-dozen individual caches... but only on memory-backed systems.

On systems with memory-backed caches, this reproduces the aggressive cascading effect.

On systems with with a default configuration (SQL+ArrayCache), this is closer to the old behavior. The bulk of the cache remains available in SQL.

Based on local spot-checking, this restores performance of the test suite.

----------------------------------------

`CRM_Utils_System::flushCache()` calls `CRM_Utils_Cache::singleton()->flush()`.
In `5.3`, this triggered a cascading effect; in development of `5.4.alpha`,
some of the cascades were overzealous and we revised to get tighter control
over cascading.

With an aim to being conservative and reproducing old behavior, I previously
patched `5.4.alpha` to add several extra flushes and simulate the old cascades.
However, it wasn't really as conservative as hoped -- because the "old
behavior" depended on the environment.  This patch brings us closer the "old
behavior".

See also: https://lab.civicrm.org/dev/core/issues/284

Before (Behavior in version <=`5.3`)
----------------------------------------

On systems with memory-backed caches, `flushCache()` had an aggressive
cascading side-effect where several named caches (`settings`, etc) were also
flushed.

On systems with a default configuration (SQL+ArrayCache), `flushCache()` had a
very limited cascading effect -- it *only cleared the in-process ArrayCache*.
The bulk of the cache content was preserved in SQL.

Before (Behavior in version ~= `5.4.alpha`)
----------------------------------------

To simulate the cascading effect, `flushCache()` explicitly flushes a
half-dozen individual caches.  (These half-dozen are chosen to match the old
cascade list and exclude some new things which would problematic.)

On systems with memory-backed caches, this reproduces the aggressive cascading
effect.

On systems with a default configuration (SQL+ArrayCache), this amplifies the
flushing -- because it also destroys the underlying SQL caches.

This has the side-effect of significantly degrading performance of the test
suite.

After (Behavior with patch)
----------------------------------------

`CRM_Utils_System::flushCache` calls `CRM_Utils_Cache::singleton()->flush()`.

To simulate the cascading effect, `flushCache()` explicitly flushes a
half-dozen individual caches...  *but only on memory-backed* systems.

On systems with memory-backed caches, this reproduces the aggressive cascading
effect.

On systems with a default configuration (SQL+ArrayCache), this is closer to the
old behavior.  The bulk of the cache remains available in SQL.

Based on local spot-checking, this restores performance of the test suite.

Comments
----------------------------------------

Deep down, I don't really believe the cascading effect is a good thing.  At
some point, I'd rather just remove these bits.  But in absence of a crystal
ball to predict the side-effects of that, I think it's good to find a better
approximation of the old behavior.
@civibot
Copy link

civibot bot commented Jul 28, 2018

(Standard links)

@totten totten changed the title (dev/core#284) - System::flushCache - Reproduce legacy cache behavior. Improve test performance. (dev/core#284) System::flushCache - Reproduce legacy cache behavior. Improve test performance. Jul 28, 2018
@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton eileenmcnaughton merged commit 27786d5 into civicrm:5.4 Jul 29, 2018
@totten totten deleted the 5.4-flushcache branch July 30, 2018 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants