Although this is the opposite of many peoples typical problem, I need to increase the amount of CPU my program is using.

I have been tasked with converting an old VB6 program to perl. I have now completed it, and it is working fine (read as - the output is correct). My problem is that it is taking multiple times longer to run in PERL than the original was in VB6. Upon eyeing the process, I notice that it is only using an average of 3 - 4% of CPU while running.

Is there any way to force PERL to run faster by using more CPU time? The issue can be seen in this profiler output:

BerkeleyDB::AUTOLOAD has -1 unstacked calls in outer BerkeleyDB::__ANON__ has 1 unstacked calls in outer Total Elapsed Time = 261.6975 Seconds User+System Time = 14.43755 Seconds Exclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 46.1 6.667 6.667 124415 0.0001 0.0001 BerkeleyDB::Common::db_ge 41.0 5.924 15.515 1 5.9238 15.515 main::ProcessLog 15.0 2.167 8.834 124415 0.0000 0.0001 BerkeleyDB::_tiedHash::FE +TCH 3.89 0.561 0.561 22983 0.0000 0.0000 BerkeleyDB::Common::db_pu +t 1.36 0.197 0.757 22983 0.0000 0.0000 BerkeleyDB::_tiedHash::ST +ORE 0.11 0.016 0.016 3 0.0053 0.0053 vars::BEGIN 0.11 0.016 0.016 1 0.0160 0.0160 XSLoader::load 0.10 0.015 0.015 1 0.0150 0.0150 BerkeleyDB::Term::close_e +verything 0.10 0.015 0.015 5 0.0030 0.0030 BerkeleyDB::Hash::_db_ope +n_hash 0.00 - -0.000 1 - - DynaLoader::dl_load_file 0.00 - -0.000 1 - - DynaLoader::dl_undef_symb +ols 0.00 - -0.000 1 - - DynaLoader::dl_find_symbo +ls 0.00 - -0.000 1 - - DynaLoader::dl_install_xs +ub 0.00 - -0.000 1 - - BerkeleyDB::bootstrap 0.00 - -0.000 1 - - BerkeleyDB::constant

The main thing there being that only 14 cpu seconds out of 261 seconds of real run time is being used. This was done on a file significantly smaller than production, so I'm sure any of you can see how expensive this begins to become on time.

Any help on getting this moving at a more appropriate pace would be greatly appreciated. I am thinking about dividing the input file into multiple files and running multiple threads to speed this up, but would like to see some potential alternatives first.

Thanks!


In reply to Increasing CPU Usage/Decreasing Run Time by NathanE

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.