In order to know which modules is costing lot of RAM it would be great to have a list the modules with their memory impact.
Created attachment 121271 [details] [review] Bug 28411: [DO NOT PUSH] memory_usage.pl apt install libmemory-usage-perl cd /kohadevbox/koha perl memory_usage.pl|sort -n
Created attachment 121272 [details] [review] Bug 28411: memory_usage.pl output
Created attachment 157956 [details] [review] Bug 28411: Use lazy loading to reduce memory footprint of C4/Context.pm This simply removes some 'use' declarations at the top of the file to instead use 'require' later on. The effect can be validated with a simple one-liner (provided KOHA_CONF and PERL5LIB being set) perl -e "use C4::Context; while(1){sleep(1);}" And monitoring the memoring usage in tools like 'top'
Created attachment 157957 [details] [review] Bug 28411: remove Koha::Config::Syspref(s) from C4::Context Use straigth SQL queries to access systempreferences instead of relying on the ORM, thus removing all direct and indirect dependencies to Koha::Object
Added two exploratory patches. Huge effect on memory footprint, but doesn't pass tests.
Created attachment 158003 [details] [review] Bug 28411: Use lazy loading to reduce memory footprint of C4/Context.pm This simply removes some 'use' declarations at the top of the file to instead use 'require' later on. The effect can be validated with a simple one-liner (provided KOHA_CONF and PERL5LIB being set) perl -e "use C4::Context; while(1){sleep(1);}" And monitoring the memoring usage in tools like 'top'
Created attachment 158004 [details] [review] Bug 28411: remove Koha::Config::Syspref(s) from C4::Context Use straigth SQL queries to access systempreferences instead of relying on the ORM, thus removing all direct and indirect dependencies to Koha::Object To remove all dependencies between C4::Context and the db object model, we move the calls to set_preference and delete_prefence directly to the class object Koha::Config::SysPrefs C4::Context::preference remains but uses straight SQL C4::Context::set_preference moves to Koha::Config::SysPrefs::set_preference C4::Context::delete_preference moves to Koha::Config::SysPrefs::delete_preference
Created attachment 158005 [details] [review] Bug 28411: modify scripts' call to set_preference now in Koha::Config::SysPrefs All the scripts using the call C4::Context->set_preference are edited to now use Koha::Config::SysPrefs->set_preference instead of C4::Context->set_preference() One call to delete_preference moved as well
Created attachment 158006 [details] [review] Bug 28411: modify t/db_dependent tests to use Koha::Config::SysPrefs' set_preference insteand of C4::Context Some work left to be done, including missing use at top of files