4605304f62
The goal is to be able to build a database handler (dbh) and to execute queries without loading unnecessary stuff. This will be useful to reduce memory usage of daemons that need to check the database periodically The patch provides a new method Koha::Database::dbh which returns a database handler without loading the DBIx::Class schema. This method is also used by DBIx::Class, so whether you use DBI or DBIx::Class, the same method is used to initialize the connection. The patch also moves some code in order to avoid loading C4::Context: - C4::Context::timezone moves to Koha::Config - C4::Context::db_scheme2dbi moves to Koha::Database To measure memory usage I used the following commands: * before the patch: perl -MKoha::Database \ -E 'Koha::Database->schema->storage->dbh->do("select 1");' \ -E '$|=1; say $$; sleep 2' \ | while read pid; do ps -p $pid -o rss=; done * after the patch: perl -MKoha::Database \ -E 'Koha::Database->dbh->do("select 1");' \ -E '$|=1; say $$; sleep 2' \ | while read pid; do ps -p $pid -o rss=; done It will give you the RSS (Resident Set Size) of the perl process in kB What I get: * before the patch: between 96.9MB and 97.2MB * after the patch: between 17.8MB and 18.2MB Note that if a timezone is configured (either from $KOHA_CONF or TZ environment variable), Koha will load DateTime::Timezone to check if it's valid, and it increases RSS to 36MB Another interesting metric is the number of modules loaded: * before the patch: perl -MKoha::Database \ -E 'Koha::Database->schema->storage->dbh;' \ -E 'say scalar keys %INC' Result: 567 * after the patch: perl -MKoha::Database \ -E 'Koha::Database->dbh;' \ -E 'say scalar keys %INC' Result: 51 Test plan: 1. Apply the patch & restart starman 2. Make sure Koha is still ok (ie. can access the database, does not have encoding issues, ...) 3. Run the tests in t/Context.t, t/Koha/Config.t, t/db_dependent/Koha/Database.t, t/timezones.t Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> |
||
---|---|---|
.. | ||
Acquisition | ||
api/v1 | ||
Auth | ||
AuthoritiesMarc | ||
Authority | ||
Biblio | ||
Circulation | ||
CourseReserves | ||
Creators | ||
cronjobs | ||
data | ||
Exporter | ||
Holds | ||
Illrequest | ||
Items | ||
Koha | ||
Labels | ||
LDAP | ||
Letters | ||
Members | ||
misc/translator | ||
OAI | ||
Patron | ||
Record | ||
Reports | ||
Reserves | ||
Search | ||
selenium | ||
Serials | ||
SIP | ||
Template/Plugin | ||
Utils | ||
www | ||
00-strict.t | ||
01-test_dbic.t | ||
Accounts.t | ||
Acquisition.t | ||
Amazon.t | ||
ArticleRequests.t | ||
AudioAlerts.t | ||
Auth.t | ||
Auth_with_cas.t | ||
Auth_with_ldap.t | ||
AuthorisedValues.t | ||
AuthoritiesMarc.t | ||
AuthUtils.t | ||
BackgroundJob.t | ||
Barcodes.t | ||
Barcodes_ValueBuilder.t | ||
Biblio.t | ||
Breeding.t | ||
Budgets.t | ||
Cache.t | ||
Calendar.t | ||
Charset.t | ||
check_kohastructure.t | ||
check_sysprefs.t | ||
Circulation.t | ||
Clubs.t | ||
Context.t | ||
Contract.t | ||
CourseReserves.t | ||
db_structure.t | ||
DecreaseLoanHighHolds.t | ||
Filter_MARC_ViewPolicy.t | ||
Fines.t | ||
FrameworkPlugin.t | ||
Heading.t | ||
Heading_MARC21.t | ||
Hold.t | ||
Holds.t | ||
HoldsQueue.t | ||
Holidays.t | ||
Illcomments.t | ||
Illrequestattributes.t | ||
Illrequests.t | ||
ILSDI_Services.t | ||
ImportBatch.t | ||
ImportExportFramework.t | ||
Installer.t | ||
Items.t | ||
Koha.t | ||
Koha_Authority.t | ||
Koha_Database.t | ||
Koha_Elasticsearch.t | ||
Koha_ExternalContent_OverDrive.t | ||
Koha_ExternalContent_RecordedBooks.t | ||
Koha_Misc_Files.t | ||
Languages.t | ||
Letters.t | ||
LibraryGroups.t | ||
Linker_Default.t | ||
Linker_FirstMatch.t | ||
Log.t | ||
MarcModificationTemplates.t | ||
Members.t | ||
Message.t | ||
MungeMarcPrice.t | ||
Overdues.t | ||
Passwordrecovery.t | ||
Patroncards.t | ||
PatronLists.t | ||
Patrons.t | ||
Record.t | ||
RecordProcessor_EmbedSeeFromHeadings.t | ||
Reports.t | ||
Reserves.t | ||
rollingloans.t | ||
RotatingCollections.t | ||
Search.t | ||
Serials.t | ||
Serials_2.t | ||
Service.t | ||
ShelfBrowser.t | ||
Sitemapper.t | ||
Stats.t | ||
StockRotationItems.t | ||
StockRotationRotas.t | ||
StockRotationStages.t | ||
SuggestionEngine_ExplodedTerms.t | ||
Suggestions.t | ||
sysprefs.t | ||
TablesSettings.t | ||
Tags.t | ||
Templates.t | ||
TestBuilder.t | ||
Upload.t | ||
UsageStats.t | ||
Virtualshelves.t | ||
XISBN.t | ||
XSLT.t | ||
yaml.t | ||
zebra_config.pl |