Pardon my noob-ness. Let me add some more details and try to answer some questions. The code is running as a mod_perl app so I would think all of this code would be loaded when the server is started up. I do need all of them loaded since I dont know when they might be used. Unfortunately use of use parent isnt that easy in my ecosystem. We have development environments on 5.8 still and other environments on 5.20.2. That wrinkle aside, I am stuck with this hardware and configuration, I need to make due with what I am given.

So the unsplit file looks a little more like this.

package ThisIsMyPackge; package Foo; package A our @ISA = qw{Foo}; sub validate { do something; } package B our @ISA = qw{Foo}; sub validate { do something; } package C our @ISA = qw{Foo}; sub validate { do something; } package Bar; package D our @ISA = qw{Bar} sub apply { do something; } package E our @ISA = qw{Bar} sub apply { do something; } package F our @ISA = qw{Bar} sub apply { do something; }

And the split version now looks like this:

package ThisIsMyPackge; use A; use B; use C; use D; use E; use F; use 79 more times ... .....

I didnt use Benchmark, I used Time::HiRes to calculate the time it takes to run the foreach loop (modified) below. The timings are based on average of 5 runs through the code. I have done more runs but the results dont differ so I use 5 for my calculations. Note this foreach loop isnt called in ThisIsMyPackge.pm, its called from another file.

unsplit: .14858s

split: .4153s

foreach my $bar (@{$objects}) { my $foo = $bar->object; .... next unless $foo->validate; $bar->apply; .... }

I put it in other timings to isolate the bottleneck and the slow down is around the $foo->validate and $bar->apply calls. All of the other logic in the loop has its timings almost exactly the same. The results from Devel::NYTProf also point to this area of the code as well. This might not seem like a lot of time but over the course of thousands of concurrent hits, it is a pretty big decrease in performance.


In reply to Re^2: Splitting large module by jimmygoogle
in thread Splitting large module by jimmygoogle

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.