Solved

Speed Up Execution of Perl LWP Module

Posted on 2004-04-19
8
525 Views
Last Modified: 2012-08-13
I used to have a site on a shared server running Sun Solaris 5.8 and Perl 5.6.1. We have now moved to a dedicated Linux server running Red Hat Enterprise Linux V3, Cpanel/Web Host Manager (latest), and  Perl 5.8.1. I have a perl script that collects images from a site on the web and downloads them to our server. Typcially processing between 100 to 1000 at a time. I've noticed a slight performance decrease since moving to the new RHEL server. When processing 30 urls it takes about 10 seconds longer then before. Although this difference is minor, the lag really shows up when processing thousands of images at a time. What are potential causes of the noticeable descrease in my Perl scripts performance when utilizing the LWP module?

What steps can I take to improve this.
0
Comment
Question by:davef8
  • 3
  • 2
8 Comments
 
LVL 20

Expert Comment

by:jmcg
Comment Utility
Other people have reported on Perl 5.8 being considerably slower than Perl 5.6. You might try installing the latest version of the Perl 5.6 stream in parallel with your already-installed 5.8 and do a speed comparison.

(The evidence I've seen so far points to a heavier UTF-8 support in 5.8 vs 5.6 as one of the culprits in the slowdown. I don't know of an easy way to improve the performance while keeping the benefits of the newer version.)

The LWP module has a number of specialized features that may enable you to improve the performance (at the expense of simplicity). Using these, you may be able to reduce the number of times data is copied from memory to memory or disk to disk. Look at the options for the 'get' and 'request' methods and consider whether you can take control of the data earler in the download process, either in chunks as it comes in or by (a :content_cb) or by specifying the destination file in advance (with a :content_file).
0
 

Author Comment

by:davef8
Comment Utility
Do you have any links to informaiton on this: "The LWP module has a number of specialized features that may enable you to improve the performance (at the expense of simplicity)."

I'll try using 5.6 as well.
0
 
LVL 20

Expert Comment

by:jmcg
Comment Utility
Sorry, it's in the LWP::UserAgent doc:

http://search.cpan.org/~gaas/libwww-perl-5.79/lib/LWP/UserAgent.pm

Under the heading REQUEST METHODS, see the descriptions for methods

$ua->get( $url )

and

$ua->request( $request )
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 20

Expert Comment

by:jmcg
Comment Utility
You might also want to check out whether using LWP::Parallel::UserAgent will help by overlapping the requests. If the requests are distributed across multiple servers, you may be able to decrease your overall run time by running the requests in parallel.

http://search.cpan.org/author/MARCLANG/ParallelUserAgent-2.57/lib/LWP/Parallel/UserAgent.pm

0
 

Author Comment

by:davef8
Comment Utility
It turns out this issue had nothing to do with perl itself. The lag was a result of network traffic.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
Comment Utility
PAQed, with points refunded (500)

Netminder
EE Admin
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now