Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Thanks for all suggestions, I will investigate these further and report back. To clarify my problem here's an example
sub someMethod { my $this = isa( ref $_[0], 'Package::Path::Module' ) ? shift : die( +'Package::Path::Module::someMethod called with uninstantiated object. +'); # ... }
Replaced with something like:
sub someMethod { =PERL_INCLUDE my $this = isa( ref $_[0], 'Package::Path::Module' ) ? shift : die( +'Package::Path::Module::someMethod called with uninstantiated object. +'); =PERL_INCLUDE # ... }
With the shebang in calling script stating something like:
#!/usr/bin/perl -Wall -POD_PERL_INCLUDE
to include the POD section.

The instantiation check exists in every object/instance method (with a similar check for class-only methods) - with a massive number of subroutine calls, this really hits performance across all the code.
( I know there's quicker ways of checking correct instantiation, but it's still a check that becomes unnecessary for production code )
There are many other checks that could also be excluded.

Our logging already works using sub refs to a dummy subroutine to avoid endless if($obj->{'DEBUG'}){ ... } calls so no gains to be made there.

I think we may have exhausted the majority of optimisation tricks - avoiding these kind of checks shaves off approximately 1/4 of the total run time.
I found this (via "man perlbot")
1 Do not attempt to verify the type of $self. That'll break if the class is inherited, when the type of $self is valid but its pack- age isn't what you expect. See rule 5.
2 If an object-oriented (OO) or indirect-object (IO) syntax was used, then the object is probably the correct type and there's no need to become paranoid about it. Perl isn't a paranoid language anyway. If people subvert the OO or IO syntax then they probably know what they're doing and you should let them do it. See rule 1.


Though object orientated, we've avoided inheritance, but I still disagree with the above because not checking how a method is called has already caused hours of scratched heads and bug hunting - so we do need these checks at dev level, but only at dev...

Thanks for all comments.

cheers,
Caspar

In reply to Re: Conditional Interpretation? by earcam
in thread Conditional Interpretation? by earcam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found