Hi
I have a gui-based tool written in perl tk which can run jobs in thousands. But we are trying to scale up the gui so that it can run nearly 1lac job without getting hung.
The code base is very huge and comprised of near about 60-70 module files. It uses socket connection for inter-process communication and MySQL for storing data. I need to profile this huge perl code base to know what could be the bottlenecks for running lacs of jobs and how can I overcome that ?
Can anybody please suggest me any good mechanism to know the bottlenecks and do profiling. I have come to know about Devel::NYFTProf but not quite able to understand how to use it. The gui has a launching script which in turn calls some more scripts using some modules.
I have come to know of following things but not quite sure how can they be helpful and how to find out his problem in my huge code

1.Avoid->repeated->chains->of->accssors(..) . Instead use temprorary variables.
Question is how come it will help if I avoid repeated chains of function call and use temp variable. Also how can I look in my huge code where all such chain calls are happening?

2. Use faster accessors as
Class::Accessor
-> Class::Accessor::Fast
---> Class::Accessor::Faster
----->Class::XSAccessor

3. Avoid calling subs that don't do anything. How can I detect this ? Any mechanism ?

4. Exit subs and loops early , delay initialization

return if not ... a cheap test...; return if not ... a more expensive test..; my $foo = ..initialization...; ...body of sub routine ...
5. Fixing silly code as below :
return exists $hash{$a}{$key}?$hash{$a}{$key} : undef; return $hash{$a}{$key}; # instead of above

Thanks

In reply to how to improve the performance of a perl program by ghosh123

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.