Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv6168/src/freenet/node/rt
Modified Files:
ResponseTimeEstimator.java
Log Message:
6204:
Fix major bug in ResponseTimeEstimator that may have had significant impact on routing
estimates esp. probability.
Logging (one message that got logged a LOT and not very useful, in CH.sending())
Logging in RTE
Index: ResponseTimeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/ResponseTimeEstimator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ResponseTimeEstimator.java 19 Sep 2003 18:49:20 -0000 1.7
+++ ResponseTimeEstimator.java 20 Sep 2003 19:58:59 -0000 1.8
@@ -50,6 +50,7 @@
static final BigInteger keyspace = BigInteger.ONE.shiftLeft(KEYBYTES << 3);
static final BigInteger halfkeyspace =
BigInteger.ONE.shiftLeft((KEYBYTES << 3) - 1);
+ boolean logDEBUG = true;
public int getDataLength() {
return 4 + key.length * (4 + KEYBYTES);
@@ -108,9 +109,11 @@
} catch (IOException ioe) {
recentPtr = recentCount = 0;
}
+ logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
}
public void writeTo(DataOutputStream o) throws IOException {
+ logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
logDEBUG("Serializing to disk, accuracy "+time.length);
o.writeInt(1); // current version. Using negative numbers for compatibility.
o.writeInt(time.length);
@@ -155,28 +158,28 @@
}
private void logMINOR(String s) {
- if(Core.logger.shouldLog(Logger.MINOR))
+ if(Core.logger.shouldLog(Logger.MINOR,this))
Core.logger.log(this, s+" ("+this+")", Logger.MINOR);
}
private static void slogMINOR(String s) {
- if(Core.logger.shouldLog(Logger.MINOR))
+ if(Core.logger.shouldLog(Logger.MINOR,ResponseTimeEstimator.class))
Core.logger.log(ResponseTimeEstimator.class,
s, Logger.MINOR);
}
private void logDEBUG(String s) {
- if(Core.logger.shouldLog(Logger.DEBUG,this))
+ if(logDEBUG)
Core.logger.log(this, s+" ("+this+")", Logger.DEBUG);
}
private void logNORMAL(String s) {
- if(Core.logger.shouldLog(Logger.NORMAL))
+ if(Core.logger.shouldLog(Logger.NORMAL,this))
Core.logger.log(this, s+" ("+this+")", Logger.NORMAL);
}
private static void slogNORMAL(String s) {
- if(Core.logger.shouldLog(Logger.NORMAL))
+ if(Core.logger.shouldLog(Logger.NORMAL,ResponseTimeEstimator.class))
Core.logger.log(ResponseTimeEstimator.class,
s, new Exception("debug"), Logger.NORMAL);
}
@@ -292,7 +295,8 @@
final MySorter ms = new MySorter();
protected void orderKeys() {
- Core.logger.log(this, "Reordering keys", Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "Reordering keys", Logger.DEBUG);
dumpLog();
// We cannot simply find the lowest value and then shift,
// Becuase we are not using anything like strict gravity
@@ -314,10 +318,11 @@
int initialSteps,
int lowerBoundPos,
int upperBoundPos) {
- Core.logger.log(this, "reportDecreasing("+lowerBound.toString(16)+","+
- upperBound.toString(16)+","+center.toString(16)+","+
- initialSteps+","+lowerBoundPos+","+upperBoundPos+")",
- new Exception("debug"), Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "reportDecreasing("+lowerBound.toString(16)+","+
+ upperBound.toString(16)+","+center.toString(16)+","+
+ initialSteps+","+lowerBoundPos+","+upperBoundPos+")",
+ new Exception("debug"), Logger.DEBUG);
dumpLog();
if(upperBoundPos >= key.length-1)
upperBoundPos = key.length - 1;
@@ -345,9 +350,10 @@
if(time[i] < 0)
Core.logger.log(this, "time["+i+"] = "+time[i]+
" - NEGATIVE TIME!", Logger.ERROR);
- Core.logger.log(this, "Trying key["+i+"]: "+
- key[i].toString(16)+","+time[i],
- Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "Trying key["+i+"]: "+
+ key[i].toString(16)+","+time[i],
+ Logger.DEBUG);
if(sensitivity[i] > SENSITIVITY_MAX)
sensitivity[i] = SENSITIVITY_MAX;
double sens = sensitivity[i];
@@ -378,13 +384,30 @@
if(key[i].compareTo(keyspace) == 1)
key[i] = key[i].subtract(keyspace);
int timediff = usec - time[i];
+ if(logDEBUG)
+ Core.logger.log(this, "usec="+usec+", time["+i+"]="+time[i]+
+ ", timediff="+timediff,
+ Logger.DEBUG);
double fracTimediff = (double)timediff;
+ if(logDEBUG)
+ Core.logger.log(this, "fracTimediff="+fracTimediff,
+ Logger.DEBUG);
double resultTimediff = fracTimediff/(sens+1.0);
+ if(logDEBUG)
+ Core.logger.log(this, "resultTimediff="+resultTimediff,
+ Logger.DEBUG);
timediff = ((int)resultTimediff) >> shiftAmount;
- timediff = (timediff*3)/4;
+ if(logDEBUG)
+ Core.logger.log(this, "timediff now = "+timediff,
+ Logger.DEBUG);
+ timediff = (int)((((long)timediff)*3)/4);
+ if(logDEBUG)
+ Core.logger.log(this,"time["+i+"] = "+time[i]+", timediff = "+
+ timediff, Logger.DEBUG);
time[i] += timediff;
- Core.logger.log(this, "key["+i+"] now: "+key[i].toString(16)+
- ","+time[i], Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "key["+i+"] now: "+key[i].toString(16)+
+ ","+time[i], Logger.DEBUG);
if(time[i] < 0)
Core.logger.log(this, "time["+i+"] = "+time[i]+
" - NEGATIVE TIME!", Logger.ERROR);
@@ -402,10 +425,11 @@
int initialSteps,
int lowerBoundPos,
int upperBoundPos) {
- Core.logger.log(this, "reportDecreasing("+lowerBound.toString(16)+","+
- upperBound.toString(16)+","+center.toString(16)+","+
- initialSteps+","+lowerBoundPos+","+upperBoundPos+")",
- new Exception("debug"), Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "reportIncreasing("+lowerBound.toString(16)+","+
+ upperBound.toString(16)+","+center.toString(16)+","+
+ initialSteps+","+lowerBoundPos+","+upperBoundPos+")",
+ new Exception("debug"), Logger.DEBUG);
dumpLog();
if(upperBoundPos >= key.length-1)
upperBoundPos = key.length - 1;
@@ -430,9 +454,10 @@
}
if(lowerBoundPos > upperBoundPos) return initialSteps;
for(int i=upperBoundPos;i>=lowerBoundPos;i--) {
- Core.logger.log(this, "Trying key["+i+"]: "+
- key[i].toString(16)+","+time[i],
- Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "Trying key["+i+"]: "+
+ key[i].toString(16)+","+time[i],
+ Logger.DEBUG);
if(time[i] < 0)
Core.logger.log(this, "time["+i+"] = "+time[i]+
" - NEGATIVE TIME!", Logger.ERROR);
@@ -457,10 +482,11 @@
double fracTimediff = (double)timediff;
double resultTimediff = fracTimediff/(sens+1.0);
timediff = ((int)resultTimediff) >> shiftAmount;
- timediff = (timediff*3)/4;
+ timediff = (int)((((long)timediff)*3)/4);
time[i] += timediff;
- Core.logger.log(this, "key["+i+"] now: "+key[i].toString(16)+
- ","+time[i], Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "key["+i+"] now: "+key[i].toString(16)+
+ ","+time[i], Logger.DEBUG);
sensitivity[i] += 1.0/(1<<shiftAmount);
shiftAmount++;
if(time[i] < 0)
@@ -472,6 +498,7 @@
}
public synchronized void report(Key k, int usec) {
+ logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
BigInteger n = convert(k);
if(usec < 0) throw new IllegalArgumentException("negative usec in report()");
@@ -484,14 +511,16 @@
int pos = search(n);
- Core.logger.log(this, "report("+n.toString(16)+","+usec+")",
- Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "report("+n.toString(16)+","+usec+")",
+ Logger.DEBUG);
dumpLog();
int x = n.compareTo(halfkeyspace);
if(x == 1) {
- Core.logger.log(this, "Above half keyspace",
- Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "Above half keyspace",
+ Logger.DEBUG);
// We are above the half way point
// n ... keyspace, 0 ... n-halfkeyspace moved left
// n-halfkeyspace ... n moved right
@@ -502,8 +531,9 @@
reportIncreasing(m, n, n, usec, 0, mpos+1, key.length-1);
orderKeys(); // if the edge wraps, over the next section, then we
orderKeys before the next section is done, we are stuffed
} else if(x == -1) {
- Core.logger.log(this, "Below half keyspace",
- Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "Below half keyspace",
+ Logger.DEBUG);
// We are below the half way point
// n ... n+halfkeyspace moved left
// 0 ... n moved right
@@ -515,8 +545,9 @@
reportIncreasing(c, keyspace, n, usec, steps, cpos+1, key.length-1);
orderKeys();
} else {
- Core.logger.log(this, "Dead on half keyspace",
- Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "Dead on half keyspace",
+ Logger.DEBUG);
// We are in the exact center
int mpos = search(halfkeyspace);
reportIncreasing(BigInteger.ZERO, halfkeyspace, halfkeyspace, usec,
@@ -525,8 +556,9 @@
0, mpos+1, key.length-1);
orderKeys();
}
- Core.logger.log(this, "report("+n.toString(16)+","+usec+") completed",
- Logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "report("+n.toString(16)+","+usec+") completed",
+ Logger.DEBUG);
// Descending...
// if (pos > 0) {
// for (int g = 0, i = pos; ++g < KEYBYTES << 3 && i >= 0; i--)
@@ -717,6 +749,7 @@
}
public int guess(BigInteger n) {
+ logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
int pos = search(n);
// It's off the charts...
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs