diff --git a/core/java/src/net/i2p/stat/BufferedStatLog.java b/core/java/src/net/i2p/stat/BufferedStatLog.java index f1aa5f338..0d20737e8 100644 --- a/core/java/src/net/i2p/stat/BufferedStatLog.java +++ b/core/java/src/net/i2p/stat/BufferedStatLog.java @@ -29,6 +29,8 @@ public class BufferedStatLog implements StatLog { private String _lastFilters; private BufferedWriter _out; private String _outFile; + /** short circuit for adding data, set to true if some filters are set, false if its empty (so we can skip the sync) */ + private volatile boolean _filtersSpecified; private static final int BUFFER_SIZE = 1024; private static final boolean DISABLE_LOGGING = false; @@ -44,6 +46,7 @@ public class BufferedStatLog implements StatLog { _lastWrite = _events.length-1; _statFilters = new ArrayList(10); _flushFrequency = 500; + _filtersSpecified = false; I2PThread writer = new I2PThread(new StatLogWriter(), "StatLogWriter"); writer.setDaemon(true); writer.start(); @@ -51,6 +54,7 @@ public class BufferedStatLog implements StatLog { public void addData(String scope, String stat, long value, long duration) { if (DISABLE_LOGGING) return; + if (!shouldLog(stat)) return; synchronized (_events) { _events[_eventNext].init(scope, stat, value, duration); _eventNext = (_eventNext + 1) % _events.length; @@ -72,6 +76,7 @@ public class BufferedStatLog implements StatLog { } private boolean shouldLog(String stat) { + if (!_filtersSpecified) return false; synchronized (_statFilters) { return _statFilters.contains(stat) || _statFilters.contains("*"); } @@ -88,11 +93,18 @@ public class BufferedStatLog implements StatLog { _statFilters.clear(); while (tok.hasMoreTokens()) _statFilters.add(tok.nextToken().trim()); + if (_statFilters.size() > 0) + _filtersSpecified = true; + else + _filtersSpecified = false; } } _lastFilters = val; } else { - synchronized (_statFilters) { _statFilters.clear(); } + synchronized (_statFilters) { + _statFilters.clear(); + _filtersSpecified = false; + } } String filename = _context.getProperty(StatManager.PROP_STAT_FILE); @@ -146,7 +158,7 @@ public class BufferedStatLog implements StatLog { updateFilters(); int cur = start; while (cur != end) { - if (shouldLog(_events[cur].getStat())) { + //if (shouldLog(_events[cur].getStat())) { String when = null; synchronized (_fmt) { when = _fmt.format(new Date(_events[cur].getTime())); @@ -164,7 +176,7 @@ public class BufferedStatLog implements StatLog { _out.write(" "); _out.write(Long.toString(_events[cur].getDuration())); _out.write("\n"); - } + //} cur = (cur + 1) % _events.length; } _out.flush(); diff --git a/history.txt b/history.txt index 5ad82613a..7910fecfc 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,9 @@ -$Id: history.txt,v 1.467 2006/05/02 23:30:28 complication Exp $ +$Id: history.txt,v 1.468 2006/05/03 06:13:29 complication Exp $ + +2006-05-04 jrandom + * Short circuit a highly congested part of the stat logging unless its + required (may or may not help with a synchronization issue reported by + andreas) 2006-05-03 Complication * Allow a single build attempt to proceed despite 1-minute overload diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index ed47c4fa4..2e4967be8 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.407 $ $Date: 2006/05/02 23:30:27 $"; + public final static String ID = "$Revision: 1.408 $ $Date: 2006/05/03 06:13:29 $"; public final static String VERSION = "0.6.1.17"; - public final static long BUILD = 6; + public final static long BUILD = 7; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID);