[Bug 15350] New: DBIx::Class Startup speed
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15350 Bug ID: 15350 Summary: DBIx::Class Startup speed Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: jonathan.druart@bugs.koha-community.org Reporter: jonathan.druart@bugs.koha-community.org QA Contact: testopia@bugs.koha-community.org (This follows 15341 comment 5) From https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/Manual/Cookb... There are some tips to follow to reduce the DBIx::Class startup delays. === 1 - Statically Define Your Schema If you are using DBIx::Class::Schema::Loader to build the classes dynamically based on the database schema then there will be a significant startup delay. For production use a statically defined schema (which can be generated using DBIx::Class::Schema::Loader to dump the database schema once - see make_schema_at and dump_directory for more details on creating static schemas from a database). 2 - Move Common Startup into a Base Class Typically DBIx::Class result classes start off with use base qw/DBIx::Class::Core/; __PACKAGE__->load_components(qw/InflateColumn::DateTime/); If this preamble is moved into a common base class:- package MyDBICbase; use base qw/DBIx::Class::Core/; __PACKAGE__->load_components(qw/InflateColumn::DateTime/); 1; and each result class then uses this as a base:- use base qw/MyDBICbase/; then the load_components is only performed once, which can result in a considerable startup speedup for schemas with many classes. 3 - Explicitly List Schema Result Classes The schema class will normally contain __PACKAGE__->load_classes(); to load the result classes. This will use Module::Find to find and load the appropriate modules. Explicitly defining the classes you wish to load will remove the overhead of Module::Find and the related directory operations: __PACKAGE__->load_classes(qw/ CD Artist Track /); If you are instead using the load_namespaces syntax to load the appropriate classes there is not a direct alternative avoiding Module::Find. 4 - MEMORY USAGE Cached statements DBIx::Class normally caches all statements with prepare_cached(). This is normally a good idea, but if too many statements are cached, the database may use too much memory and may eventually run out and fail entirely. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15350 --- Comment #1 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- 1 - Already done 2 - We don't load any components at the moment 3 - In Koha::Schema, I have tried to replace __PACKAGE__->load_namespaces; with my $r = [ qw( Accountline Accountoffset ... Zebraqueue ) ]; __PACKAGE__->load_classes({ 'Koha::Schema::Result' => $r}); I have not noticed any gain using the following script use Koha::Database; Koha::Database->new()->schema()->resultset('Discharge'); Always between 0.85 and 0.90 second 4 - Something to try? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15350 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |15342 Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15342 [Bug 15342] Performance 3.22 - Omnibus -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15350 Jacek Ablewicz <abl@biblos.pk.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |abl@biblos.pk.edu.pl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15350 Frédéric Demians <frederic@tamil.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |frederic@tamil.fr --- Comment #2 from Frédéric Demians <frederic@tamil.fr> --- Created attachment 45606 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=45606&action=edit DBIX call stacks This graph show the time spent in DBIx::Class::Schema::load_namespace by a script which does nothing but creating a connection to Koha DB. It take half a second on recent CPU. The question for me is whether the schema creation, which implies creating thousand of classes, is redone each time a Koha page is loaded, or if it's cached under Plack. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15350 Heather Braum <hbraum@nekls.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hbraum@nekls.org -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org