Re: [Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-23 Thread David Wright

Jonathan Rockway wrote:

* On Mon, Feb 23 2009, Jason Gottshall wrote:
  

Oleg Pronin wrote:


  I use many actions that take params from config in runtime, for example
  sub pay_for_vip : Private {
   ...
   my $price = $c->cfg->{vip}{price};
  }
  

As I understand it, this is NOT the way config is intended to
work. All the config for your component (controller in this case) is
passed to the constructor at setup time; all you need to do is make
accessors for whatever you want access to:

  __PACKAGE__->mk_accessors(qw/vip/);

  sub pay_for_vip : Private {
  ...
  my $price = $self->vip->{price};
  }



Yes, exactly.

This is another case of the all-too-frequent "change Catalyst so that I
won't have to change any code in my poorly-implemented app".
  

Jeez. That's a little harsh, though I sympathise with the general point.

We use the Catalyst config file to initialize Catalyst components, to 
initialise non-Catalyst configuration objects, and also to provide via 
config() a simple runtime interface to 'get this key/value pair'. We 
store other (runtime) conf values in the db, wrapped with memcached, to 
avoid having to deploy a config file if we need timely changes. Many of 
our conf values are shared between components, not directly relevant to 
components, or are most readably kept together as a discrete 
configuration set, rather than added per component. Finally, given the 
size of our conf file, I don't think we'd want to clutter either our 
packages with accessors, or our project with classes that merely wrap 
configuration sets.

I don't think the patch will be harmful, though, so if there is one we
might as well apply it.  But it's a lot easier to not misuse config than
it is to patch Catalyst to make the misuse faster.
  
I can't see anywhere in the docs where this 'intended use' is stated. 
That's not to say that it isn't there.


Having said all that, our app must call config 10s of million times a 
day, and we've never perceived it to be a bottleneck.


Regards,
David


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-23 Thread Jonathan Rockway
* On Mon, Feb 23 2009, Jason Gottshall wrote:
> Oleg Pronin wrote:
>>   I use many actions that take params from config in runtime, for example
>>   sub pay_for_vip : Private {
>>...
>>my $price = $c->cfg->{vip}{price};
>>   }
>
> As I understand it, this is NOT the way config is intended to
> work. All the config for your component (controller in this case) is
> passed to the constructor at setup time; all you need to do is make
> accessors for whatever you want access to:
>
>   __PACKAGE__->mk_accessors(qw/vip/);
>
>   sub pay_for_vip : Private {
>   ...
>   my $price = $self->vip->{price};
>   }

Yes, exactly.

This is another case of the all-too-frequent "change Catalyst so that I
won't have to change any code in my poorly-implemented app".

I don't think the patch will be harmful, though, so if there is one we
might as well apply it.  But it's a lot easier to not misuse config than
it is to patch Catalyst to make the misuse faster.

Regards,
Jonathan Rockway

--
print just => another => perl => hacker => if $,=$"

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-23 Thread Jason Gottshall

Oleg Pronin wrote:

  I use many actions that take params from config in runtime, for example
  sub pay_for_vip : Private {
   ...
   my $price = $c->cfg->{vip}{price};
  }


As I understand it, this is NOT the way config is intended to work. All 
the config for your component (controller in this case) is passed to the 
constructor at setup time; all you need to do is make accessors for 
whatever you want access to:


  __PACKAGE__->mk_accessors(qw/vip/);

  sub pay_for_vip : Private {
  ...
  my $price = $self->vip->{price};
  }

--
Jason Gottshall
jgottsh...@capwiz.com


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-22 Thread Jonathan Rockway
* On Sun, Feb 22 2009, Oleg Pronin wrote:
> And in my deepest opinion we should now spend CPU time anywhere even if it is 
> not a
> concern.

You forgot to attach the patch.  

Seriously, you obviously think this is worth spending time on, so spend
the time on it, and it will be fixed for everyone!  That is what free
software is all about.

Regards,
Jonathan Rockway

--
print just => another => perl => hacker => if $,=$"

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-22 Thread Oleg Pronin
1% here and 1% there. You won't detect any place that takes longer. All of
load is 1%+1%+
Don't you agree ? Plus a number of plugins calls ->config on startup which
slow downs startup as well)

P.S.
  I use many actions that take params from config in runtime, for example
  sub pay_for_vip : Private {
   ...
   my $price = $c->cfg->{vip}{price};
  }

And in my deepest opinion we should now spend CPU time anywhere even if it
is not a concern.

Thanks anyway)

This is convenient + good HUP support for deamon servers (that use catalyst
as well) - all you need to do is to refresh config on HUP.

2009/2/22 Jonathan Rockway 

> * On Sat, Feb 21 2009, Oleg Pronin wrote:
> > I use Catalyst in extremely loaded projects (currently 60.000.000
> pageloads / day).
> > Thereforce i'm perfomance paranoid man.
> >
> > One of 'black stones' is the ->config method. It has dramatically slow
> perfomance at
> > config_method:  1 wallclock secs ( 1.06 usr +  0.00 sys =  1.06 CPU) @
> 3808.94/s (n=
> > 4047)
>
> I have to ask... is this actually slowing down your application?  Let's
> say that your app spends 1% of its time in $c->config.  If you made
> $c->config 1x faster, you would only make your app 1% faster.
>
> > It would be VERY GREAT if we somehow make ->config works a hundred
> > times faster because everybody use ->config without any suspicions on
> > its speed.
>
> Although I haven't noticed config calls slowing down my application, I
> look forward to seeing your patch for this.
>
> FWIW, I usually only call $c->config at app startup time; I read it and
> pass values in it as arguments to other classes that need configuration
> information.  I'm pretty sure this is the intended use; you shouldn't be
> looking in it during requests.
>
> Regards,
> Jonathan Rockway
>
> --
> print just => another => perl => hacker => if $,=$"
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-22 Thread Oleg Pronin
*we should now -> we should not :-)

2009/2/22 Oleg Pronin 

> 1% here and 1% there. You won't detect any place that takes longer. All of
> load is 1%+1%+
> Don't you agree ? Plus a number of plugins calls ->config on startup which
> slow downs startup as well)
>
> P.S.
>   I use many actions that take params from config in runtime, for example
>   sub pay_for_vip : Private {
>...
>my $price = $c->cfg->{vip}{price};
>   }
>
> And in my deepest opinion we should now spend CPU time anywhere even if it
> is not a concern.
>
> Thanks anyway)
>
> This is convenient + good HUP support for deamon servers (that use catalyst
> as well) - all you need to do is to refresh config on HUP.
>
> 2009/2/22 Jonathan Rockway 
>
> * On Sat, Feb 21 2009, Oleg Pronin wrote:
>> > I use Catalyst in extremely loaded projects (currently 60.000.000
>> pageloads / day).
>> > Thereforce i'm perfomance paranoid man.
>> >
>> > One of 'black stones' is the ->config method. It has dramatically slow
>> perfomance at
>> > config_method:  1 wallclock secs ( 1.06 usr +  0.00 sys =  1.06 CPU) @
>> 3808.94/s (n=
>> > 4047)
>>
>> I have to ask... is this actually slowing down your application?  Let's
>> say that your app spends 1% of its time in $c->config.  If you made
>> $c->config 1x faster, you would only make your app 1% faster.
>>
>> > It would be VERY GREAT if we somehow make ->config works a hundred
>> > times faster because everybody use ->config without any suspicions on
>> > its speed.
>>
>> Although I haven't noticed config calls slowing down my application, I
>> look forward to seeing your patch for this.
>>
>> FWIW, I usually only call $c->config at app startup time; I read it and
>> pass values in it as arguments to other classes that need configuration
>> information.  I'm pretty sure this is the intended use; you shouldn't be
>> looking in it during requests.
>>
>> Regards,
>> Jonathan Rockway
>>
>> --
>> print just => another => perl => hacker => if $,=$"
>>
>> ___
>> List: Catalyst@lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive:
>> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>>
>
>
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-21 Thread Jonathan Rockway
* On Sat, Feb 21 2009, Oleg Pronin wrote:
> I use Catalyst in extremely loaded projects (currently 60.000.000 pageloads / 
> day).
> Thereforce i'm perfomance paranoid man.
>
> One of 'black stones' is the ->config method. It has dramatically slow 
> perfomance at
> config_method:  1 wallclock secs ( 1.06 usr +  0.00 sys =  1.06 CPU) @ 
> 3808.94/s (n=
> 4047)

I have to ask... is this actually slowing down your application?  Let's
say that your app spends 1% of its time in $c->config.  If you made
$c->config 1x faster, you would only make your app 1% faster.

> It would be VERY GREAT if we somehow make ->config works a hundred
> times faster because everybody use ->config without any suspicions on
> its speed.

Although I haven't noticed config calls slowing down my application, I
look forward to seeing your patch for this.

FWIW, I usually only call $c->config at app startup time; I read it and
pass values in it as arguments to other classes that need configuration
information.  I'm pretty sure this is the intended use; you shouldn't be
looking in it during requests.

Regards,
Jonathan Rockway

--
print just => another => perl => hacker => if $,=$"

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Maybe there is a need for some speedups of 'config' method ?

2009-02-21 Thread Oleg Pronin
Hello. Catalyst is the best MVC ever. Thanks for doing your work guys!

I use Catalyst in extremely loaded projects (currently 60.000.000 pageloads
/ day).
Thereforce i'm perfomance paranoid man.

One of 'black stones' is the ->config method. It has dramatically slow
perfomance at
config_method:  1 wallclock secs ( 1.06 usr +  0.00 sys =  1.06 CPU) @
3808.94/s (n=4047)

it has 2 workarounds:
1) use 'state' feature of perl 5.10

sub my_action {
state $cfg = $c->config;
}

2) create inherited accessor
   MyApp->mk_group_accessors(inherited => qw/cfg/);
   sub finalize_setup {
$class->cfg($class->config);
   }

cfg_accessor:  2 wallclock secs ( 1.03 usr +  0.00 sys =  1.03 CPU) @
237252.85/s (n=244667)
config_method:  1 wallclock secs ( 1.06 usr +  0.00 sys =  1.06 CPU) @
3808.94/s (n=4047)

It would be VERY GREAT if we somehow make ->config works a hundred times
faster because everybody use
->config without any suspicions on its speed.
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/