logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian.H...@equifax.com
Subject RE: MDC copies
Date Fri, 30 Jan 2004 21:42:10 GMT
None of the changes I have made should add any serious performance
overhead.

Old behavior:
MDC.put("name", "value"); (get is similar)
- get thread local map
- get value from tlm
- if value is null
   - new Hashtable
   - put new hashtable in tlm
- hashtable.put("name", "value");

New behavior:
- get thread local map
- get value from tlm
- if value is null
   - getFactory (singleton)
   - factory.create (just calls new BasicMDCContainer which is just a
subclass of hashtable)
   - put new container in tlm
- container.put("name", "value");

(Logger is not affected)

No other code is run unless you use async appender, and that just calls
clone on the container (delegates to the parent hashtable) by default.


I think maybe my explanation was unclear. This is a very low overhead
change. Should I just send it for folks to look at?

-----Original Message-----
From: ceki@qos.ch [mailto:ceki@qos.ch] 
Sent: Friday, January 30, 2004 4:03 PM
To: Log4J Developers List
Subject: RE: MDC copies



Christian,

Adding functionality with computational overhead which is only used with

AsyncAppender, does not make sense to me. AsyncAppender is there for 
performance reasons. Logging asynchronously should not be much slower
than 
direct logging.

Unless I am missing something, I think the changes you propose will be 
counterproductive.

At 08:08 AM 1/30/2004 -0500, Christian.Hall@equifax.com wrote:
>I have completed the modifications to support a pluggable MDC 
>container. It consists of four new files and patches to ThreadLocalMap,

>MDC and LoggingEvent.
>
>The Web site is not clear on coding conventions or how to send new 
>files (it talks about diff, but I have multiple files...do I just post 
>a huge diff?). I am finishing testing today and will be ready to 
>contribute. Can someone tell me how best to send?
>
>-Christian
>
>
>A summary of the design:
>
>Two new plug points have been added:
>- MDCContainer: an interface; represents the Map that will hold MDC 
>context and has copy() method (replaces Hashtable)
>- MDCContainerFactory: an interface; factory used by MDC to create new 
>containers (replaces new Hashtable())
>
>I have provided a BasicMDCContainer and BasicMDCContainerFactory that 
>deliver the existing Hashtable implementation by default.
>
>ThreadLocalMap has been modified to expect an MDCContainer and uses its
>copy() method to make the copy when a child thread is created.
>
>MDC has been modified to use the factory to create the container and 
>any references to Hashtable have been replaced with MDCContainer. The 
>factory is a static property and get/set has been added. To plug in a 
>new container, one just does MDC.setContainerFactory.
>
>LoggingEvent now uses MDCContainer.copy() in its getMDCCopy method.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



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


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


Mime
View raw message