Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv28058/src/freenet/node/rt

Modified Files:
        NGRoutingTable.java StandardNodeEstimator.java 
        NodeEstimator.java 
Log Message:
6336:
Don't take pSearchFailed into account AT ALL in estimators, rely entirely on backoff. 
Should make for more accurate estimators, better routing. The estimators for timeouts 
and QRs are wrong anyway.
Sort by time left on backoff, after lastSuccess and conns, and before successes. 
Should fix new nodes being dropped rather than old backed off nodes. Thanks supple for 
idea.

Index: NGRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NGRoutingTable.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -w -r1.41 -r1.42
--- NGRoutingTable.java 14 Nov 2003 01:14:32 -0000      1.41
+++ NGRoutingTable.java 15 Nov 2003 01:02:32 -0000      1.42
@@ -507,6 +507,7 @@
                final long createdTime;
                final int successes;
                final int consecutiveConnectionFailures; //0 if connected
+               final int backoff;
                
                public String toString() {
                        return "NGRT.MyDiscardValue: lastSuccess="+lastSuccess+
@@ -515,12 +516,13 @@
                }
                
                MyDiscardValue(long success, long access, long created,
-                                          int successes, int connFailures) {
+                                          int successes, int connFailures, int 
backoff) {
                        lastSuccess = success;
                        lastAccess = access;
                        this.successes = successes;
                        createdTime = created;
                        consecutiveConnectionFailures = connFailures;
+                       this.backoff = backoff;
                }
                
                public int compareTo(Object c) {
@@ -537,6 +539,9 @@
                           o.consecutiveConnectionFailures) return 1;
                        if(consecutiveConnectionFailures < 
                           o.consecutiveConnectionFailures) return -1;
+                       // Higher = longer backoff = worse
+                       if(backoff > o.backoff) return 1;
+                       if(backoff < o.backoff) return -1;
                        // Higher = more successes = better
                        if(successes < o.successes) return 1;
                        if(successes > o.successes) return -1;
@@ -580,9 +585,10 @@
                        }
                        ret = new MyDiscardValue(ne.lastSuccessTime(), 
                                                                         
ne.lastAccessedTime(), ne.createdTime(), 
-                                                                        
ne.successes(),x);
+                                                                        
ne.successes(),x, ne.backoffLength());
                } else
-                       ret = new MyDiscardValue(-1, -1, -1, 0, 0);
+                       ret = new MyDiscardValue(-1, -1, -1, 0, Integer.MAX_VALUE, 
+                                       Integer.MAX_VALUE);
                Core.logger.log(this, "Returning "+ret,
                                                Logger.DEBUG);
                return ret;

Index: StandardNodeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/StandardNodeEstimator.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -w -r1.42 -r1.43
--- StandardNodeEstimator.java  14 Nov 2003 10:40:40 -0000      1.42
+++ StandardNodeEstimator.java  15 Nov 2003 01:02:32 -0000      1.43
@@ -240,15 +240,15 @@
                double estimate = 0F;
                // First the simple failures
                // would it be better just to remove the connectionFailed stuff...  edt
-               double pConnectFailed = needConnection ? 
rpConnectFailed.currentValue() : 0;
-               double tConnectFailed = needConnection ? 
rtConnectFailed.currentValue() : 0;
-               estimate = (pConnectFailed * (tConnectFailed + requestFailTime));
-               double pSearchFailed = rpSearchFailed.currentValue();
+//             double pConnectFailed = needConnection ? 
rpConnectFailed.currentValue() : 0;
+//             double tConnectFailed = needConnection ? 
rtConnectFailed.currentValue() : 0;
+//             estimate = (pConnectFailed * (tConnectFailed + requestFailTime));
+//             double pSearchFailed = rpSearchFailed.currentValue();
                double tSearchFailed = rtSearchFailed.currentValue();
                double pTransferFailed = rpTransferFailed.currentValue();
                double tTransferFailed = rtTransferFailed.currentValue();
-               estimate += (pSearchFailed * (tSearchFailed + requestFailTime)) +
-                       (pTransferFailed * (tTransferFailed + requestFailTime));
+//             estimate += (pSearchFailed * (tSearchFailed + requestFailTime)) +
+//                     (pTransferFailed * (tTransferFailed + requestFailTime));
                // DNF probability does not incorporate CF or QR
                // Now DataNotFound
                double pDNF =epDNFGivenNotSearchFailed.guessProbability(k);
@@ -257,13 +257,13 @@
 //             if (pDNF==0.0)
 //                     pDNF = pLegitDNF;
                double tDNF = etDNF.guessTime(k) * htl;
-               double pNotConnectFailedOrSearchFailed =
-                       (1 - pConnectFailed) * (1- pSearchFailed);
-               estimate += pNotConnectFailedOrSearchFailed 
-                       * (pDNF - pLegitDNF) * (tDNF + requestFailTime);
+//             double pNotConnectFailedOrSearchFailed =
+//                     (1 - pConnectFailed) * (1- pSearchFailed);
+               estimate += /*pNotConnectFailedOrSearchFailed * */
+                       (pDNF - pLegitDNF) * (tDNF + requestFailTime);
                // Success
-               double pSuccess = pNotConnectFailedOrSearchFailed
-                       * (1 - pDNF);
+               double pSuccess = /*pNotConnectFailedOrSearchFailed * */
+                       (1 - pDNF);
                double transferRate, tSuccessSearch;
                if(pSuccess > 1 || pSuccess < 0) {
                        Core.logger.log(this, "pSuccess = "+pSuccess, Logger.ERROR);
@@ -283,10 +283,10 @@
                        if(Core.logger.shouldLog(Logger.MINOR, this))
                                Core.logger.log(this, toString()+".estimate(): 
rFT="+requestFailTime
                                                +", needConn="+needConnection+", 
size="+size+", key="+
-                                               k+", htl="+htl+", 
pConnectFailed="+pConnectFailed
+                                               k+", htl="+htl+/*", 
pConnectFailed="+pConnectFailed
                                                +", tConnectFailed="+tConnectFailed
                                                                +", 
pSearchFailed="+pSearchFailed+", tSearchFailed="+
-                                                               tSearchFailed+", 
pTransferFailed="+pTransferFailed+
+                                                               tSearchFailed+*/", 
pTransferFailed="+pTransferFailed+
                                                                ", 
tTransferFailed="+tTransferFailed+", pDNF="+pDNF+
                                                                ", tDNF="+tDNF+", 
pLegitDNF="+pLegitDNF
                                                                +", 
tSuccess="+tSuccess+", transferRate="+transferRate+
@@ -980,5 +980,13 @@
                if(enteredBackoffTime + currentBackoffPeriod > now)
                        return true;
                else return false;
+       }
+
+       public int backoffLength() {
+               long now = System.currentTimeMillis();
+               long end = enteredBackoffTime + currentBackoffPeriod;
+               if(end < now)
+                       return 0;
+               return (int)(end - now);
        }
 }

Index: NodeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NodeEstimator.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -w -r1.18 -r1.19
--- NodeEstimator.java  14 Nov 2003 01:14:32 -0000      1.18
+++ NodeEstimator.java  15 Nov 2003 01:02:32 -0000      1.19
@@ -137,4 +137,10 @@
         * @return Whether we are currently backed off
         */
        abstract public boolean isBackedOff();
+
+       /**
+        * @return The period of time remaining on the current backoff,
+        * or 0 if we are not backed off.
+        */
+       abstract public int backoffLength();
 }

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to