logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Endre StĂžlsvik <En...@Stolsvik.com>
Subject Re: log4j 1.2.15
Date Thu, 22 Feb 2007 13:14:28 GMT
> I've added a few additional dependencies to the 1.2.15 release bug 
> (40951).  If anyone has a favorite bug that should go into 1.2.15, 
> please mention it or add it as a dependency on the bug.

Last time I looked at the code, the NDC was implemented using a
"homebrewed" ThreadLocal (static map keyed on Thread)

When checking out the code from svn, I see that the trunk (1.3) uses
ThreadLocal, while the 1.2 branch uses the old stuff.

This "homebrewed" approach has some serious disadvantages, in particular
that it is prone to be filled with garbage if one forgets to
NDC.remove() (or one is thrown out before this for some reason) (and
that this again leads to whole classloaders of classes that can never be
released), but more seriously, it sucks performance wise (full
contention for all codepaths using the NDC, both on the NDC-push/pop,
but also on the appender/formatter side).

ThreadLocal from java >=1.3 reverses the Map, using a Map within the
Thread, keying on the ThreadLocal. This then doesn't need synching.
There is, however, still an issue with leaking classloaders
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6254531), but not
worse than it is now for the NDC. (There exists a patch that fixes this,
which apparently will be included at some point. Please vote on the
sun-bug if you find it interesting, check the comment about Tomcat's
leaking on webapp reloads).

Basically, what I'm asking for is that the NDC in trunk is simply
backported to the 1.2 branch. There should be no other effects of this
other than speed increases; ThreadLocal was in java from 1.2 on.

PS: The MDC have similar problems - and could also benefit from simply 
using ThreadLocal for the storage of the Hashtable that holds the MDC 

Kind regards,

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message