RE: utf8::SWASHNEW

2005-05-12 Thread Christopher Fry
> -Original Message-
> From: Greg Matheson [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 02, 2005 5:47 PM
> To: perl-unicode@perl.org
> Subject: Re: utf8::SWASHNEW
> 
> On Mon, 02 May 2005, Christopher Fry wrote:
> 
> > One of the things we gathered from our profiling was that more of the
> SWASH*
> > activity in our apps was happening around regexes. We took a closer look
> > and, for the regexes that could never have unicode values (e.g. for
> internal
> > URL checking), we just scoped them and did a "use bytes" within that
> scope.
> > It helped, but not to the degree that we thought it would.
> 
> > Turns out the act of profiling the code actually exacerbated the
> frequency
> > of these SWASH* functions. Instrumenting suspect functions outside of
> > profiling demonstrated that.
> 
> How did you show that? Would running code in the debugger also have an
> effect? Here is the profile for Kwiki's index.cgi below.
> 30 percent of the time is in utf8::SWASHNEW.

We turned off the profiler and ran the same code test path but with some
print STDERR stuck in the actual SWASH function. Then we compared the counts
of those prints vs what the profiler was telling us and saw a difference of
2-3 orders of magnitude.

> 
> > > -Original Message-
> > > From: Rafael Garcia-Suarez [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, April 29, 2005 8:58 AM
> > > To: perl-unicode@perl.org
> > > Subject: Re: utf8::SWASHNEW
> 
> > > Eric Cholet wrote in perl.unicode :
> > > > I just did a profiling on one of my programs, and it turns out it
> > > > spends most of its time in utf8::SWASHNEW. In second place is one of
> my
> > > > own functions, and in third place comes utf8::SWASHGET. What do
> > > > SWASHNEW and SWASHGET do ? (in layman's terms-- I browsed the source
> > > > but it gave me a headache). Is this a price to pay when using Perl
> > > > unicode strings?
> 
> > > They're used to load and initialise the swatchs, ie. internal hashes
> > > that contain unicode properties (sets of unicode chars, e.g.
> > > alphabetics, etc).
> 
> > > So, they're typically called rarely. Can you post an example of code
> > > that reproduces the problem ?
> 
> Here's no code, but running Kwiki's index.cgi from the command
> line with perl -d:DProf index.cgi, produces this profile:
> 
> %Time ExclSec CumulS #Calls sec/call Csec/c  Name
>  30.4   1.178  0.000 98   0.0120 0.  utf8::SWASHNEW
>  4.80   0.186  0.329106   0.0018 0.0031  Spiffy::import
>  4.54   0.176  1.541   3103   0.0001 0.0005  Spiffy::__ANON__
>  3.72   0.144  1.517 19   0.0076 0.0798  Spoon::Hub::load_class
>  3.69   0.143  0.143   2743   0.0001 0.0001  overload::mycan
>  3.48   0.135  0.291143   0.0009 0.0020  Spiffy::field
>  3.20   0.124  0.113436   0.0003 0.0003  Spiffy::parse_arguments
>  3.10   0.120  0.168  8   0.0149 0.0210  Template::Config::load
>  3.07   0.119  0.332 10   0.0119 0.0332  Spoon::Base::BEGIN
>  2.94   0.114  0.303236   0.0005 0.0013  Carp::caller_info
>  2.71   0.105  0.105   4374   0. 0.
> Filter::Util::Call::filter_read
>  2.32   0.090  0.090  8   0.0112 0.0112  CGI::_compile
>  2.04   0.079  0.174 10   0.0079 0.0174  Template::BEGIN
>  1.94   0.075  1.280332   0.0002 0.0039
> Spoon::Formatter::Unit::match_phra
>  se
>  1.81   0.070  0.089  4   0.0175 0.0223  Spoon::Cookie::BEGIN
> 
> 30 percent of the time in utf8::SWASHNEW!
> 
> --
> Greg Matheson, Taiwan


Re: utf8::SWASHNEW

2005-05-02 Thread Greg Matheson
On Mon, 02 May 2005, Christopher Fry wrote:

> One of the things we gathered from our profiling was that more of the SWASH*
> activity in our apps was happening around regexes. We took a closer look
> and, for the regexes that could never have unicode values (e.g. for internal
> URL checking), we just scoped them and did a "use bytes" within that scope.
> It helped, but not to the degree that we thought it would.

> Turns out the act of profiling the code actually exacerbated the frequency
> of these SWASH* functions. Instrumenting suspect functions outside of
> profiling demonstrated that.

How did you show that? Would running code in the debugger also have an
effect? Here is the profile for Kwiki's index.cgi below.
30 percent of the time is in utf8::SWASHNEW.

> > -Original Message-
> > From: Rafael Garcia-Suarez [mailto:[EMAIL PROTECTED]
> > Sent: Friday, April 29, 2005 8:58 AM
> > To: perl-unicode@perl.org
> > Subject: Re: utf8::SWASHNEW

> > Eric Cholet wrote in perl.unicode :
> > > I just did a profiling on one of my programs, and it turns out it
> > > spends most of its time in utf8::SWASHNEW. In second place is one of my
> > > own functions, and in third place comes utf8::SWASHGET. What do
> > > SWASHNEW and SWASHGET do ? (in layman's terms-- I browsed the source
> > > but it gave me a headache). Is this a price to pay when using Perl
> > > unicode strings?

> > They're used to load and initialise the swatchs, ie. internal hashes
> > that contain unicode properties (sets of unicode chars, e.g.
> > alphabetics, etc).

> > So, they're typically called rarely. Can you post an example of code
> > that reproduces the problem ?

Here's no code, but running Kwiki's index.cgi from the command
line with perl -d:DProf index.cgi, produces this profile:

%Time ExclSec CumulS #Calls sec/call Csec/c  Name
 30.4   1.178  0.000 98   0.0120 0.  utf8::SWASHNEW
 4.80   0.186  0.329106   0.0018 0.0031  Spiffy::import
 4.54   0.176  1.541   3103   0.0001 0.0005  Spiffy::__ANON__
 3.72   0.144  1.517 19   0.0076 0.0798  Spoon::Hub::load_class
 3.69   0.143  0.143   2743   0.0001 0.0001  overload::mycan
 3.48   0.135  0.291143   0.0009 0.0020  Spiffy::field
 3.20   0.124  0.113436   0.0003 0.0003  Spiffy::parse_arguments
 3.10   0.120  0.168  8   0.0149 0.0210  Template::Config::load
 3.07   0.119  0.332 10   0.0119 0.0332  Spoon::Base::BEGIN
 2.94   0.114  0.303236   0.0005 0.0013  Carp::caller_info
 2.71   0.105  0.105   4374   0. 0.  Filter::Util::Call::filter_read
 2.32   0.090  0.090  8   0.0112 0.0112  CGI::_compile
 2.04   0.079  0.174 10   0.0079 0.0174  Template::BEGIN
 1.94   0.075  1.280332   0.0002 0.0039  Spoon::Formatter::Unit::match_phra
 se
 1.81   0.070  0.089  4   0.0175 0.0223  Spoon::Cookie::BEGIN

30 percent of the time in utf8::SWASHNEW!

-- 
Greg Matheson, Taiwan


RE: utf8::SWASHNEW

2005-05-02 Thread Christopher Fry
One of the things we gathered from our profiling was that more of the SWASH*
activity in our apps was happening around regexes. We took a closer look
and, for the regexes that could never have unicode values (e.g. for internal
URL checking), we just scoped them and did a "use bytes" within that scope.
It helped, but not to the degree that we thought it would.

Turns out the act of profiling the code actually exacerbated the frequency
of these SWASH* functions. Instrumenting suspect functions outside of
profiling demonstrated that.

-Chris

> -Original Message-
> From: Rafael Garcia-Suarez [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 29, 2005 8:58 AM
> To: perl-unicode@perl.org
> Subject: Re: utf8::SWASHNEW
> 
> Eric Cholet wrote in perl.unicode :
> > I just did a profiling on one of my programs, and it turns out it
> > spends most of its time in utf8::SWASHNEW. In second place is one of my
> > own functions, and in third place comes utf8::SWASHGET. What do
> > SWASHNEW and SWASHGET do ? (in layman's terms-- I browsed the source
> > but it gave me a headache). Is this a price to pay when using Perl
> > unicode strings?
> 
> They're used to load and initialise the swatchs, ie. internal hashes
> that contain unicode properties (sets of unicode chars, e.g.
> alphabetics, etc).
> 
> So, they're typically called rarely. Can you post an example of code
> that reproduces the problem ?
> 
> --
> The sensation of a very small and at the same time extremely heavy object
> produced a disagreeable impression of repugnance and fear.
> -- Borges


Re: utf8::SWASHNEW

2005-04-29 Thread Rafael Garcia-Suarez
Eric Cholet wrote in perl.unicode :
> I just did a profiling on one of my programs, and it turns out it 
> spends most of its time in utf8::SWASHNEW. In second place is one of my 
> own functions, and in third place comes utf8::SWASHGET. What do 
> SWASHNEW and SWASHGET do ? (in layman's terms-- I browsed the source 
> but it gave me a headache). Is this a price to pay when using Perl 
> unicode strings?

They're used to load and initialise the swatchs, ie. internal hashes
that contain unicode properties (sets of unicode chars, e.g.
alphabetics, etc).

So, they're typically called rarely. Can you post an example of code
that reproduces the problem ?

-- 
The sensation of a very small and at the same time extremely heavy object
produced a disagreeable impression of repugnance and fear.
-- Borges