rafit has asked for the wisdom of the Perl Monks concerning the following question:

Hi, the following line in HTTP::Daemon is slowing down my proxy, (using HTTP::Proxy) by 7-8 seconds on each request.
$uri = $HTTP::URI_CLASS->new($uri, $self->daemon->url);
What is the meaning of the code above? What does it do? Where is it defined? Can it be done faster? The only thing like a definition I have seen so far is in HTTP::Message
$HTTP::URI_CLASS ||= $ENV{PERL_HTTP_URI_CLASS} || "URI";
Any help will be appreciated. Sorry, I have not been successful on CPAN. May be a guru out here can help. Best Regards, solomon.

Replies are listed 'Best First'.
Re: Delay In HTTP::Proxy
by perrin (Chancellor) on Aug 27, 2008 at 18:24 UTC
    It looks like it creates a URI object, but for it to take 7 seconds it must be calling some code that does network or disk activity. You should run Devel::NYTProf on it and see where the time is going.
Re: Delay In HTTP::Proxy
by Corion (Patriarch) on Aug 28, 2008 at 06:19 UTC

    According to this blog entry by Vipul, if you're on RedHat, the system Perl is built with a buggy patch which does slow down modules like URI quite heavily. So if you're on RedHat, you'll likely have to build your own Perl (not hard) or wait for an RPM upgrade by RedHat.

Re: Delay In HTTP::Proxy
by rafit (Initiate) on Aug 28, 2008 at 08:27 UTC
    I traced the delay to a sub in HTTP::Daemon. It returns the url of the proxy. For now, I have hard coded the address and it's working ok. I suspect it could be a DNS issue. I will look into this later (never?).
    sub daemon { my $self = shift; ${*$self}{'httpd_daemon'}; }
    Thanks, solomon.