Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Since you've only posted a general question, we can only give you general advise. In order for you to optimize a program, you must know two things. What resource is it limited by (usually CPU speed or poor code design; real memory; disk speed)? How can you restructure your code to either limit it's dependence on that resource or parallelize access to it. Others have mentioned forking/threading, but these can be hard to use if you inexperienced with them and don't have the time to learn. Some other things you may want to consider...

If your script is performing a lot of IO (reading and writing), consider separating the files onto different physical disks, and importantly don't access files through things like NFS mounts. Sometimes this alone can double the throughput, esp if you are reading and writing two files at the same time on the same physical disk.

You really do not want the system to be swapping while your program is running, since it will cause things to slow down a lot. This is often caused by trying to manipulate massively large data structures in memory in perl. If your script is using lots of memory (e.g. reading two large files completely into memory before processing), consider processing as you read each line in. If you need them in arrays, consider using something like Tie::File. One common example is trying to sort a massive array within perl itself. Sometimes you can call an external utility to do this for you much more quickly (e.g. GNU sort).

If you give more details, I'm sure someone can help out more.


In reply to Re: Taking advantage of multi-processor architecture by bluto
in thread Taking advantage of multi-processor architecture by bedanta

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 avoiding work at the Monastery: (3)
As of 2024-04-24 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found