[Koha-patches] [PATCH] Caching for authorised values

Frédéric DEMIANS f.demians at tamil.fr
Thu Jun 18 08:06:34 CEST 2009


> Indeed. In the meantime, any incremental function results caching we
> do may as well use a standard module like Memoize rather than our
> having to writing such caching by hand.
>
> I've just sent a counter-patch that introduces Memoize to cache the
> results of GetAuthorisedValues. Would you mind profiling that patch
> against your resubmission of the hand-coded caching for that function?

Indeed Memoize works impressively!

Take a look on profiling results. This is an OPAC result page displaying 
20 records -- GetAuthorisedValues in Subroutine column:

Without any caching:

    http://devel.tamil.fr/nytprof-normal/index-subs-excl.html
    221ms

With my cached hash:

    http://devel.tamil.fr/nytprof-hash/index-subs-excl.html
    18.7ms

With Memoize:

    http://devel.tamil.fr/nytprof-memoize/index-subs-excl.html
    9.7ms

I have a dream that one day Koha OPAC will return results in subsecond...

Incidentally, a function, a new one, seems to impact badly OPAC 
performances: C4::Biblio::GetCOinSBiblio. It takes 424ms. It wouldn't be 
hard to fix it. This function begin reading (re-reading) biblio record 
(GetMarcBiblio). And as we know reading biblio record implies parsing 
XML biblio record which is VERY slow. Solution 1: caching MARC::Record 
in GetMarcBiblio (Memoize). Solution 2: Calling GetCOinSBiblio with 
available MARC::Record object.

With an OO API, we wouldn't have such traps...

    my $record = Koha::BiblioRecord->read( $biblionumber );
    ...
    $html .= $record->get_coins_span();


-- 
Frédéric DEMIANS
http://www.tamil.fr/u/fdemians.html



More information about the Koha-patches mailing list