Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 62496 invoked from network); 26 Jun 2008 00:07:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jun 2008 00:07:45 -0000 Received: (qmail 58945 invoked by uid 500); 26 Jun 2008 00:07:43 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 58880 invoked by uid 500); 26 Jun 2008 00:07:42 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 58869 invoked by uid 99); 26 Jun 2008 00:07:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jun 2008 17:07:42 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 72.14.220.156 as permitted sender) Received: from [72.14.220.156] (HELO fg-out-1718.google.com) (72.14.220.156) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 00:06:53 +0000 Received: by fg-out-1718.google.com with SMTP id d23so1490533fga.24 for ; Wed, 25 Jun 2008 17:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=CX5QvH+jw2inD+D5vriMoMx16sAcs+1vFr8T5Jl2pTM=; b=lvAUlM+oLLtpbCxKgPWo66/TPyaU1/Xy8I5zSItZr57Drwdu0u2pgiQQIuRcRQiTNZ SPus3DSfs1+Q9kYm7yj8zTYGMJM2wUEg9zqg041k24XgMcxxTaw7h0GhQZJ2NXuaNiWf ncw688+udo9APgZvuYguHX/FevVCdvVbZ482k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=PLiYyNitDOwlQZrh+NmhsUh4ldY6S55H7XEFLNxPE/h1Sha2O6z7+62ClXdMDE1Z33 DbQ1hiP+XpnSk/GJqdYyhwji4/OCCigDRXq56yjM9CCUaz7HwyKXSikpu/YWHR/MrDkK usYSQV1suAcUkPjKbGXQYf++U6fpDiYpAlILE= Received: by 10.86.49.3 with SMTP id w3mr4580717fgw.14.1214438831321; Wed, 25 Jun 2008 17:07:11 -0700 (PDT) Received: by 10.86.59.4 with HTTP; Wed, 25 Jun 2008 17:07:11 -0700 (PDT) Message-ID: <25aac9fc0806251707g7a01a84dnc11801c8ee11a818@mail.gmail.com> Date: Thu, 26 Jun 2008 01:07:11 +0100 From: sebb To: "Commons Users List" Subject: Re: Strange performance issues seen with Log.isDebugEnabled() In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1214429660.17270.31.camel@simon-laptop> X-Virus-Checked: Checked by ClamAV on apache.org On 26/06/2008, Jean-Philippe Daigle wrote: > > -----Original Message----- > > From: Jean-Philippe Daigle > [mailto:Jean-Philippe.Daigle@SolaceSystems.com] > > Sent: Wednesday, June 25, 2008 6:06 PM > > To: Commons Users List > > > Subject: RE: Strange performance issues seen with Log.isDebugEnabled() > > > > > > > > > -----Original Message----- > > > From: simon [mailto:simon.kitching@chello.at] > > > Sent: Wednesday, June 25, 2008 5:34 PM > > > To: Commons Users List > > > Subject: Re: Strange performance issues seen with > Log.isDebugEnabled() > > > > > > > > > On Wed, 2008-06-25 at 17:11 -0400, Jean-Philippe Daigle wrote: > > > > [snip] > > > > > > Wow. Really weird. > > > > > Thanks for replying, my thoughts exactly. Looks like gremlins to me. > > > > > I'll try to find some time to stare at the Log class tomorrow. But > > > you've been so thorough I'm not sure what I might spot that you > > haven't > > > already seen. > > > > > > I presume you've also just tried > > > if (Trace.isDebugEnabled()) { > > > // do nothing > > > } > > > and that the performance impact is still there? > > > > Yes. The 60% throughput degradation is there. If I remove that call to > > isDebugEnabled() the throughput goes back up. > > > > > > > > > > Log is just an interface, and you say you have put in your own > > > implementation that returns immediately (presumably you also wrote a > > > LogFactory implementation that returned an instance of your Log > > type?). > > > > Sorry, should have said more about this, but my email was already too > > long! I wrote three files: Log, LogImpl, and LogFactory. Log and > > LogFactory clone the public interface of the equivalent "official" > > versions so I don't need to recompile the whole world, just switch out > a > > jar (but most methods are just empty). LogFactory returns LogImpl > > instances, which print out a debug line to stdout when constructed, to > > make absolutely sure I'm really using my own version and not the > apache > > one. I then remove the official commons-logging-1.1.1.jar file from > the > > classpath, leaving only my version. > > > > > > > So in that case > > > Trace.isDebugEnabled() > > > is exactly equivalent to > > > private static final SomeClass Trace = new SomeClass(); > > > ... > > > Trace.anyOldEmptyMethod(); > > > and it doesn't make *any* sense that that would affect performance. > So > > > are you *really* sure that your "replacement" class actually got > used? > > > > > > > Yes, it *should* be equivalent, but I've also tried defining a Dummy > > class, getting a static instance of it, and calling a dummy method > (that > > won't get optimized away) and it's fast (~80000 WU/s). Going back to > my > > custom isDebugEnabled(), boom, down to ~30000 WU/s. Unless you tell me > > that calling a method on an interface is HUGELY more expensive than a > > direct call (I don't think it is, and it wouldn't explain my > > micro-timings anyways), I have no idea what's going on. > > > > Thanks! > > Jean-Philippe Daigle > > > > > Ah, so there's one more thing I hadn't tried, which I just did, and > explained a bit of the situation: completely removing the logging block > (don't check isDebugEnabled(), don't call .debug(), etc. > > Removing the whole logging block results in getting the same slow > throughput case that I was blaming on isDebugEnabled(). > > Replacing it with just this assignment (to a public var so it's not > optimized away): > > _dbg_str = String.format("appack>>> id=%s res=%s", id, ack_r); > > Gives me the fast throughput case. Wow. So apache commons logging is > blameless, what determines whether you get the fast or the slow message > throughput case is actually _slowing down the thread calling the > ackMessage() method_. Slowing down this frequently-called method with > useless String.format() work results in more than double the throughput. > > I have no idea why (it's counterintuitive), I suspect I need to get more > visibility into the interactions between threads here. > > Thanks to everyone that read this thread, looks like the problem's > somewhere else in my code. (Though if you DO have any suggestions that > could explain what I'm seeing, let me know, even if this is no longer a > logging issue :) ) > What happens if you simplify the format to remove the ack_r parameter? Is it possible that the toString() method on that parameter is having an effect? Or perhaps try replacing the format call with a short sleep. Maybe there is some odd thread interaction that is worse when the enclosing method runs faster. Or perhaps the format code is touching a volatile variable or using a lock that allows a shared variable to be published? > > Jean-Philippe > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org