Bug 16166: Improve L1 cache performance and safety
authorJacek Ablewicz <abl@biblos.pk.edu.pl>
Tue, 26 Apr 2016 06:43:12 +0000 (08:43 +0200)
committerFrédéric Demians <f.demians@tamil.fr>
Mon, 1 Aug 2016 09:45:06 +0000 (11:45 +0200)
commit5ea4b9e549ccbb53bf98129b86de49acfd82eb4e
treed71ec96f4236f09ad7ae40aedb51124df0f1dca2
parent2b5257947aa4ac8b7fe78914722c3ac9f02b8ddc
Bug 16166: Improve L1 cache performance and safety

Bug 16044 introduced two-level caching mechanism to Koha::Cache. By
default, get_from_cache() returns a deep copy of the data structures
stored in L1 cache (aka "safe mode"). For extremely big and/or complex
data structures (like MARC framework hash-of-hashes-of-hashes returned
by GetMarcStructure() ), deep-cloning is currently sub-optimal;
this patch addresses that particular issue. It also provides an
ability to intermix "safe" and "unsafe" cache feches, in such
way that they don't interfere with each other (i.e., eliminating
the risk involved with "unsafe" calls possibly compromising
further "safe" calls).

Test plan:

1) apply patch
2) flush L2 cache if necessary (restart memcached daemon)
3) profile GetMarcStructure() calls before / after patch, e.g. by
running some script which calls it often (like catalogue search
w/ XSLT processing turned on, etc.) - GetMarcStructure() should be
faster than before, in all possible circumstances (eg. 18 msec
per call -> 10 msec p/call)
4) after testing, before returning to the master branch, flush L2 cache
again (restart memcached daemon) - otherwise all system preferences
returned from L2 cache would be suffixed with '-CF0'

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
(cherry picked from commit 2b39cc7fffbc0376190bf4b53fd70085dc5df03f)
Koha/Cache.pm