commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Philippe Daigle" <>
Subject RE: Strange performance issues seen with Log.isDebugEnabled()
Date Mon, 30 Jun 2008 21:04:49 GMT
> I suggest getting a copy of YourKit and profiling the application.
> Unfortunately, with the behavior you are seeing this might slow the
> application just enough to cause the problem to go away.  However,
> your description of the problem it sounds like you have some sort of
> contention going on that is avoiding simply by making the processing
> take a bit more time. If you take out the debugging code and stress it
> hopefully YourKit will show you where the code contention actually is.
> A brute force technique I've used in the past (which is fairly
> is just to take a few thread dumps and then look for threads that are
> the same place across the dumps or within the same dump. In a system
> without bottlenecks you wouldn't expect to see very many threads at
> same place.
> Ralph


Running it through the profiler (I have ej-technologies' JProfiler,
which I happen to like better than YourKit) finally allowed me to see
what was going on. I was looking at the whole thing too closely, from a
"what's slowing this particular thread" point of view.

Turns out (I should've suspected from the huge amount of context
switches I noted last week) that two threads were simply blocking each
other, waiting alternately on the same lock, 30000 times a second, due
to one of them doing some lengthy work in a critical section while only
a tiny portion of that work needed to be in the critical section.

The speed boost I was getting by adding the String.format() call was due
to the fact that the useless string work ever-so-slightly changed the
balance of timings in which this "greedy" thread was running, and made
the lock contention happen much less frequently. I fixed the underlying
problem and now I'm always running fast.

Thanks to everyone for the help offered, it was very useful.

Jean-Philippe Daigle

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message