Koha-clms/Koha
Jonathan Druart 985debedec Bug 11112: Koha::Calendar needs some caching
Each time a Koha::Calendar object is created, its constructor retrieves
all holidays from the database and create a DateTime::Set object with
all holidays.

[RM note: I've observed that the time it takes DateTime::Set to be
 initialized with a set of dates increases faster than linearly with
 the number of dates.  I think this, more than just retrieving a bunch
 of holidays from the database, is what is most expensive.]

In one of our customer's DB, there are 11085 special_holidays and 598
repeatable_holidays. When a loan is returned, there are 3 calls to
Koha::Calendar->new.

This patch adds caching of the holiday list via package-level variables
as well as lazy fetching of the holidays. (RM note: this means that if
a persistance engine is in use, updates to the holiday list will not
be reflected during checkout.  I'm allowing this breakage for now on
the plan that bug 8089 will be fixed soon and we can switch to using
Koha::Cache).

Nytprof benchmarks (on a 3.8.x branch):
In DateTime::Set->from_datetimes:
3 times (5.49ms+4.90s) by Koha::Calendar::_init at line 80 of Koha/Calendar.pm, avg 1.63s/call
on a total of 7.67s (of 10.2s), executing 6353333 statements and 3031273 subroutine calls in 147 source files and 36 string evals.
for the circulation/return.pl page.

Comparing the access_log:

Without the patch:
checkout: time=2759838
checkin: time=1832751

Without the patch and with overdues:
checkout: time=1086727 + time=1144706
checkin: time=3928854 (x2)

With the patch and overdues:
checkout: time=1077839 + time=1060886
checkin: time=2420898

Test plan:
- checkout an item with a return date < today
- checkin the item and verify the suspension period is well calculated
  (depending on the holidays).
- prove t/db_dependent/Holidays.t
- t/Calendar.t

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit a98b239dbf)
Signed-off-by: Fridolin SOMERS <fridolin.somers@biblibre.com>
2013-12-24 11:52:42 +01:00
..
Borrower Bug 2720: (follow-up) change license version to GPLv3+ 2013-10-31 01:56:10 +00:00
Cache Bug 9434: Introduce new tied cache system 2013-03-20 15:15:44 -04:00
Filter/MARC Bug 9620: IncludeSeeFromInSearches and data in $9 subfields can break indexing 2013-03-07 09:31:11 -05:00
Indexer Bug 10143 - Fixing license headers 2013-05-01 06:47:50 -04:00
List Bug 15065: (follow-up) update license header 2013-10-14 21:50:10 +00:00
Plugins Bug 9971 - Plugins system is broken! 2013-04-03 06:02:09 -04:00
QueryParser/Driver Bug 11137: fix certain types of searches run using QueryParser 2013-11-14 15:50:50 +00:00
RecordProcessor Bug 7417: Include see from references in bibliographic searches 2012-09-13 14:19:28 +02:00
Schema/Result Bug 11275: (follow-up) update DBIC schema class files 2013-12-13 14:47:51 +01:00
SearchEngine Bug 11015: add copyright headers to some files 2013-10-21 21:45:00 +00:00
SuggestionEngine Bug 9239: Allow the use of QueryParser for all queries 2013-03-16 21:32:32 -04:00
Template/Plugin Bug 10493: (follow-up) fix various QA issues 2013-10-22 17:05:53 +00:00
Util Bug 5202: QA follow-up: quiet warnings 2013-10-10 21:36:59 +00:00
AuthUtils.pm Bug 9611: (follow-up) move new password hashing routines to separate module 2013-10-09 03:29:22 +00:00
Authority.pm Bug 5202: QA follow-up - correct license and POD errors 2013-10-10 21:39:15 +00:00
Cache.pm Bug 9434: Introduce new tied cache system 2013-03-20 15:15:44 -04:00
Calendar.pm Bug 11112: Koha::Calendar needs some caching 2013-12-24 11:52:42 +01:00
Database.pm Bug 8798: (follow-up) remove DBIC_DONT_VALIDATE_RELS 2013-10-14 22:51:44 +00:00
DateUtils.pm Bug 10380: (follow-up) update POD to fully reflect change to output_pref() 2013-10-17 23:35:31 +00:00
Linktracker.pm Bug 8917 : [ Sign followup ] Track clicks to links external to Koha 2013-03-07 11:14:25 -05:00
MetadataRecord.pm Bug 9755 QA follow-up: move MARC-specific functionality to utility class 2013-07-23 23:10:21 +00:00
Plugins.pm Bug 9907 - Plugins test dies early on some servers 2013-03-22 17:50:09 -04:00
RecordProcessor.pm Bug 7417: Include see from references in bibliographic searches 2012-09-13 14:19:28 +02:00
Schema.pm Bug 8798: (follow-up) update the DBIC schema class files 2013-10-14 21:08:03 +00:00
SearchEngine.pm Bug 11015: add copyright headers to some files 2013-10-21 21:45:00 +00:00
SimpleMARC.pm Bug 8015: (follow-up) remove references to C4::Koha::Log 2013-10-31 22:50:29 +00:00
SuggestionEngine.pm Bug 8726: ExplodedTerms suggestion plugin (functionality) 2012-09-28 17:08:21 +02:00