On 8/22/06, Josef Chladek <[EMAIL PROTECTED]> wrote:
what we notice: in Catalyst/Model/DBIC/Schema.pm the time of the
require of the schema

$schema_class->require

is fast for the first loaded schemas (0.05s) but takes about 0.6s for
the last schemas. also time to connect

$self->schema->connection(@{$self->{connect_info}});

begins with 0.05s and goes up to 0.6s, so overall the startup process
takes now about 15s for 19 models/schemas.

Is this timed under mod_perl, or standalone?  If you're timing it under mod_perl, its probably just getting progressively slower as all of the copies get started up.  If not, can the increasing times be explained by increasing schema complexity?  At "$schema_class->require" is when load_classes runs and you should be mostly seeing Class::C3/Alg::C3/load_components/etc initialization delays (which is what I'm still working on reducing, but it may be a little while).  I'm surprised that ->connection takes any significant time in perl, are you sure this isn't a case of the DB server responding slower and slower?

If you want to find a spot in one of the public modules to improve performance, you should profile your models under Devel::Profile to point out the hotspots.  Make a script which "uses" all of your model classes, then sets up any config on them that was coming from YAML or other such sources (connect_info and/or schema class), then calls ->new on each of them and exits.  Run it w/ "perl -D:Profile testscript.pl", then look at the top entries in the generated prof.out.  This example is typical of what I usually see percentage-wise:

%Time    Sec.     #calls   sec/call  F  name
27.67    1.2513      259   0.004831     Algorithm::C3::merge
24.69    1.1163      161   0.006933     Class::C3::_calculate_method_dispatch_table
 4.52    0.2042      161   0.001269     Class::C3::_remove_method_dispatch_table
 3.64    0.1646       161   0.001023     Class::C3::_apply_method_dispatch_table
 2.97    0.1343       98   0.001370     DBIx::Class::Componentised::ensure_class_loaded
 2.75    0.1243     5837   0.000021     <anon>:...e_perl/5.8.8/Class/C3.pm:146
 1.93    0.0871      482   0.000181     DBIx::Class::AccessorGroup::_mk_group_accessors
 1.38    0.0626      183   0.000342     DBIx::Class::Schema::register_source

It was based on this kind of feedback that I focused on Alg::C3 first (its time is down substantially from what it used to be, and it might not be possible to make it significantly faster without rewriting it in XS).  Obviously the *_method_dispatch_table methods in Class::C3 are another target that needs looking at (and again, there's some work in progress on this, which involves XS code, but it might not be ready until sometime after YAPC::EU at the least).

-- Brandon
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to