[Koha-bugs] [Bug 16044] Define a L1 cache for all objects set in cache

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Mar 17 16:55:45 CET 2016


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16044

--- Comment #20 from Jacek Ablewicz <abl at biblos.pk.edu.pl> ---
Some other thoughts, after toying with these patches for a little while.

1) If we want to stay "on the safe side" by default, clone()/dclone() call
needs to be introduced to the set_in_cache() sub as well

2) Looks like Cache::Memory as L2 cache is 100% waste of time and CPU cycles.
If L2 = Cache::Memory, typically we'll be storing a lot of things in there -
small and large, but never fetching them back

3) In that statement

> - if it's a reference, return a "deep clone" of what we keep in L1 cache in
> deserialized form (that should still be way faster than fetching it from the
> network and deserializing it each and every time)

I was completely wrong :). Cloning very complex data structures, like MARC
framework hashes in Koha, is not faster in perl then deserializing them.
Cloning involves

a) traversing the whole structure recursively - inspecting all the nested parts
of it in various ways etc.
b) creating anew the copies of all those pesky hashes, hash keys, scalars etc.
in perl guts

Thawing the structure from serialized form is doing b), but not a), so it can
be faster. And it is - for the MARC default framework:

- Storable thaw() call is taking ca 10 ms
- freeze(): 6 ms
- dclone(): 17 ms
- decode_sereal(): 9 ms - probably not worth the trouble, there are no packages
in Debian for Sereal module

Memcache::Fast is using Storable thaw() as desrializer by default. Feching
framework from memcached is faster (12.5 ms) than cloning it with dclone. It
only involves two "expensive" tasks: thaw() - 10 ms, and probably decompress
(~2 ms).

This may be the problem; get_from_cache() which involves dclone() will be
significantly slower, and Koha::Cache as a whole will suffer severe performance
loss if used in the "safe" way.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list