hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ortwin Glück <ortwin.glu...@nose.ch>
Subject Re: AW: Logging
Date Thu, 30 Dec 2004 11:12:23 GMT

Thanks for digging into HttpClient performance wise. This is not 
something that is done often. That's why I appreciate this discussion. I 
would like to encourage others to join and make proposals for 
performance enhancements as well. I think HttpClient is quite fast, but 
I am sure we can make it even faster.

Pfingstl Gernot wrote:
> Hi Ortwin, you say that you can achieve only 4% performance gain. But
> you calculate, that logging will perform. In a production environment
> logging should be not the normal case. 

No, I measured the production case, where no single line was logged at 
all. See attached log4j.properties file that I used. The level is set to 
WARN, and the code logs with DEBUG.

The performance gain of a guarded call to the log method is actually 
independent of the log level. It is only for measuring reasons that I 
turned off logging by setting the level high enough. If you log, you 
basically end up measuring the performance of the output stream.

 > So you
> will have 10% performace gain. 

No, you won't. 10% is *per call* to a log method. HttpClient does a lot 
more besides logging. I said in my original email, that only in *extreme 
cases* the ratio of log overhead can be as much as 40% (NoHostTest 
suite). In a normal application it will drop below 5% because of network 
IO I guess. If your application does much more than using HttpClient 
(i.e. is not a spider),  the ratio will be even better:
  Calls to HttpClient in your app: 10%
  Log overhead in HttpClient: 5%
  Perceived log overhead: 5%*10% = 0.5%
  Perceived effect of tuning HttpClient: 0.5%*10% = 0.05%

Studies say, that for desktop applications a performance gain of less 
than 50% (fifty) is normally not noticed by a user. Have you ever 
noticed a performance increase in a desktop application (say Word, 
Photoshop, Explorer) at all, btw? For server-side code I would say, that 
anything above 10% is worth doing.

Do i need to say more?

 > But only if you have constant
> strings. In httpclient-3.0-beta1 there are also dynamic log
> strings!

Yes, there are some. And they are (should be) all guarded.
I quickly checked and only found one occurrence (in DigestScheme) where 
a guard was missing. If we missed some, feel free to open a bug report 
and tell us where a guard is missing.

> In my opinion a "commons" library should the best possible
> performance, because the libraries only a small piece of the
> application(s) especially in a J2EE environment. Of course the
> guarded code looks bad, but I don't know a better solution.

This is my opinion as well. And I have another one: "Write scalable 
code. Don't waste performance. Pinpoint bottlenecks. Tune where it is 

Can you provide profiling data of your application that shows that 
HttpClient's logging is a considerable bottleneck? If so, my fellow 
developers and I will try with best effort to eliminate the bottleneck.

Have a nice start to the day

Ortwin Glück

View raw message