[
http://jira.jboss.com/jira/browse/JGRP-484?page=comments#action_12360673 ]
Bela Ban commented on JGRP-484:
-------------------------------
The program below measured that for 1 million log statements (with tracing turned OFF for
'bla'), the overhead of if(log.isTraceEnabled()) compared to if(trace) was 16 ms,
so that's negligible.
--------------------------- code ------------------
package org.jgroups.tests;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Bela Ban
* @version $Id$
*/
public class bla {
final static int NUM=1000 * 1000;
public static void main(String[] args) throws Exception {
Log log=LogFactory.getLog(bla.class);
testWithCaching(log);
testWithoutCaching(log);
testWithCaching(log);
testWithoutCaching(log);
}
private static void testWithCaching(Log log) {
long start, stop, diff;
boolean trace=log.isTraceEnabled();
start=System.nanoTime();
for(int i=0; i < NUM; i++) {
if(trace) {
log.trace("testing");
}
}
stop=System.nanoTime();
diff=stop - start;
System.out.println(NUM + " with caching: " + diff + " ns (" +
diff / 1000000 + " ms)");
}
private static void testWithoutCaching(Log log) {
long start, stop, diff;
start=System.nanoTime();
for(int i=0; i < NUM; i++) {
if(log.isTraceEnabled()) {
log.trace("testing");
}
}
stop=System.nanoTime();
diff=stop - start;
System.out.println(NUM + " without caching: " + diff + " ns ("
+ diff / 1000000 + " ms)");
}
}
---------------- output -----------------
1000000 with caching: 4803404 ns (4 ms)
1000000 without caching: 24840308 ns (24 ms)
1000000 with caching: 377981 ns (0 ms)
1000000 without caching: 19888841 ns (19 ms)
Dynamically configure logging at runtime
----------------------------------------
Key: JGRP-484
URL:
http://jira.jboss.com/jira/browse/JGRP-484
Project: JGroups
Issue Type: Feature Request
Reporter: Bela Ban
Assigned To: Bela Ban
Priority: Minor
Fix For: 2.6
For performance reasons, JGroups caches log levels as follows:
boolean trace=log.isTraceEnabled();
// later:
if(trace) {
log.trace(...);
}
While caching created a measurable performance increase, it also disabled the ability to
change the log levels at runtime (example: JBoss' log4j.xml, which is re-read every 60
secs).
Investigate how to have both good performance and dynamic runtime configuration of log
levels. E.g. signal to enable logging ?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira