You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Ken Clark <mk...@mindspring.com> on 2003/03/26 06:25:53 UTC

HttpClient and CPU usage.....

I've built a b2b application using the commons HttpClient, and all works
extremely well.  The problem is, however, that the app is using up to 45% of
the CPU time ( as reported by various unix processes ( ps -aux, vmstat,
etc ) ).  The customer has a Sun 4500, running solaris, with two processors.

I've tried debugging the app's CPU usage using the -Xrunhprof:cpu=samples
parameter in the VM, and it returns the "hot spots" for CPU usage :

   1 74.67% 74.67% java/net/SocketInputStream.read      ([BII)I
   2  9.61% 84.28% java/net/PlainSocketImpl.available   ()I
   3  8.51% 92.79% java/net/PlainSocketImpl.doConnect
(Ljava/net/InetAddress;I)V

everything else is using less than 0.50% of the VMs CPU.

Since I'm not using these classes directly, I'm assuming that HttpClient is.
How can I make my app use less of the CPU?


Re: HttpClient and CPU usage.....

Posted by Sam Maloney <sa...@filogix.com>.
Good call Tom, this is most definatly the problem!

As the 'busy loop' that has been fixed that you speak of would have caused 
this EXACT occurance.

The bug caused HttpClient to continually call the Socket's 'int 
InputStream->read()' over and over even though the socket is allready closed 
(the function is returning -1, but it is being ignored, and thus called again 
and again inside a while loop that does nothing but calling 
InputStream->read() :).

Ken,
I almost guarantee this is your problem. If you are using a version older than 
aprox 2 weeks ago, upgrade to cvs. I am also not sure if Alpha 3 contains the 
fix; however, the fix was provided and approved a few days before alpha3 came 
around, so it should be in there.

Cheers,
Sam Maloney

On Wednesday 26 March 2003 11:10, Tom Samplonius wrote:
>   What version of httpclient are you using?
>
>   I understand that a busy read loop was removed from httpclient a couple
> of weeks ago.  I'm not sure if this change was made for Alpha3, or whether
> you have to go the daily builds to get it.
>
> Tom
>
> On Wed, 26 Mar 2003, Ken Clark wrote:
> > I've built a b2b application using the commons HttpClient, and all works
> > extremely well.  The problem is, however, that the app is using up to 45%
> > of the CPU time ( as reported by various unix processes ( ps -aux,
> > vmstat, etc ) ).  The customer has a Sun 4500, running solaris, with two
> > processors.
> >
> > I've tried debugging the app's CPU usage using the -Xrunhprof:cpu=samples
> > parameter in the VM, and it returns the "hot spots" for CPU usage :
> >
> >    1 74.67% 74.67% java/net/SocketInputStream.read      ([BII)I
> >    2  9.61% 84.28% java/net/PlainSocketImpl.available   ()I
> >    3  8.51% 92.79% java/net/PlainSocketImpl.doConnect
> > (Ljava/net/InetAddress;I)V
> >
> > everything else is using less than 0.50% of the VMs CPU.
> >
> > Since I'm not using these classes directly, I'm assuming that HttpClient
> > is. How can I make my app use less of the CPU?
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional
> > commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional
> commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


RE: HttpClient and CPU usage.....

Posted by Ken Clark <mk...@mindspring.com>.
Thank you all for your assistance.  I downloaded the nightly drop yesterday
and will go about compiling it today and testing under JDK 1.4.

-----Original Message-----
From: Oleg Kalnichevski [mailto:o.kalnichevski@dplanet.ch]
Sent: Wednesday, March 26, 2003 1:09 PM
To: Commons HttpClient Project
Subject: Re: HttpClient and CPU usage.....


Busy wait has been fixed after 2.0a3 release. So, a recent nightly build
is needed. Besides, it turned out that Ken was using a rather old JDK
(1.2) which is known to have rather lousy JIT on Solaris platform. I
have already recommended Ken to upgrade both the JDK and the HttpClient

Cheers

Oleg

On Wed, 2003-03-26 at 17:10, Tom Samplonius wrote:
>   What version of httpclient are you using?
>
>   I understand that a busy read loop was removed from httpclient a couple
> of weeks ago.  I'm not sure if this change was made for Alpha3, or whether
> you have to go the daily builds to get it.
>
> Tom
>
>
> On Wed, 26 Mar 2003, Ken Clark wrote:
>
> > I've built a b2b application using the commons HttpClient, and all works
> > extremely well.  The problem is, however, that the app is using up to
45% of
> > the CPU time ( as reported by various unix processes ( ps -aux, vmstat,
> > etc ) ).  The customer has a Sun 4500, running solaris, with two
processors.
> >
> > I've tried debugging the app's CPU usage using
the -Xrunhprof:cpu=samples
> > parameter in the VM, and it returns the "hot spots" for CPU usage :
> >
> >    1 74.67% 74.67% java/net/SocketInputStream.read      ([BII)I
> >    2  9.61% 84.28% java/net/PlainSocketImpl.available   ()I
> >    3  8.51% 92.79% java/net/PlainSocketImpl.doConnect
> > (Ljava/net/InetAddress;I)V
> >
> > everything else is using less than 0.50% of the VMs CPU.
> >
> > Since I'm not using these classes directly, I'm assuming that HttpClient
is.
> > How can I make my app use less of the CPU?
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org


Re: HttpClient and CPU usage.....

Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Busy wait has been fixed after 2.0a3 release. So, a recent nightly build
is needed. Besides, it turned out that Ken was using a rather old JDK
(1.2) which is known to have rather lousy JIT on Solaris platform. I
have already recommended Ken to upgrade both the JDK and the HttpClient

Cheers

Oleg

On Wed, 2003-03-26 at 17:10, Tom Samplonius wrote:
>   What version of httpclient are you using?
> 
>   I understand that a busy read loop was removed from httpclient a couple
> of weeks ago.  I'm not sure if this change was made for Alpha3, or whether
> you have to go the daily builds to get it.
> 
> Tom
> 
> 
> On Wed, 26 Mar 2003, Ken Clark wrote:
> 
> > I've built a b2b application using the commons HttpClient, and all works
> > extremely well.  The problem is, however, that the app is using up to 45% of
> > the CPU time ( as reported by various unix processes ( ps -aux, vmstat,
> > etc ) ).  The customer has a Sun 4500, running solaris, with two processors.
> > 
> > I've tried debugging the app's CPU usage using the -Xrunhprof:cpu=samples
> > parameter in the VM, and it returns the "hot spots" for CPU usage :
> > 
> >    1 74.67% 74.67% java/net/SocketInputStream.read      ([BII)I
> >    2  9.61% 84.28% java/net/PlainSocketImpl.available   ()I
> >    3  8.51% 92.79% java/net/PlainSocketImpl.doConnect
> > (Ljava/net/InetAddress;I)V
> > 
> > everything else is using less than 0.50% of the VMs CPU.
> > 
> > Since I'm not using these classes directly, I'm assuming that HttpClient is.
> > How can I make my app use less of the CPU?
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> 


Re: HttpClient and CPU usage.....

Posted by Tom Samplonius <to...@sdf.com>.
  What version of httpclient are you using?

  I understand that a busy read loop was removed from httpclient a couple
of weeks ago.  I'm not sure if this change was made for Alpha3, or whether
you have to go the daily builds to get it.

Tom


On Wed, 26 Mar 2003, Ken Clark wrote:

> I've built a b2b application using the commons HttpClient, and all works
> extremely well.  The problem is, however, that the app is using up to 45% of
> the CPU time ( as reported by various unix processes ( ps -aux, vmstat,
> etc ) ).  The customer has a Sun 4500, running solaris, with two processors.
> 
> I've tried debugging the app's CPU usage using the -Xrunhprof:cpu=samples
> parameter in the VM, and it returns the "hot spots" for CPU usage :
> 
>    1 74.67% 74.67% java/net/SocketInputStream.read      ([BII)I
>    2  9.61% 84.28% java/net/PlainSocketImpl.available   ()I
>    3  8.51% 92.79% java/net/PlainSocketImpl.doConnect
> (Ljava/net/InetAddress;I)V
> 
> everything else is using less than 0.50% of the VMs CPU.
> 
> Since I'm not using these classes directly, I'm assuming that HttpClient is.
> How can I make my app use less of the CPU?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> 
> 
>