On 2003-09-21 at 03:01, Edward J. Huff wrote:

> So I'm going to replace the queryreject decision with
> a probabilistic decision.

I am currently running my node with similar code. There has not been
much interest at all in it. It works well for me.


/Benny


--- freenet-orig/src/freenet/node/Node.java	2003-08-23 02:06:59.000000000 +0200
+++ freenet/src/freenet/node/Node.java	2003-08-22 20:34:39.000000000 +0200
@@ -2420,15 +2428,36 @@
             return true;
         }
 
-	// Node is slightly overloaded
-        if ((load < overloadHigh) &&
-            (ft.contains(searchKey) || 
-             ds.contains(searchKey))) {
-	    if (inboundRequests != null) {
-		inboundRequests.incSuccesses(diagAddr);
+	// Node is loaded
+        if (load < overloadHigh) {
+	    if ((ft.contains(searchKey) || ds.contains(searchKey))) {
+		if (inboundRequests != null) {
+		    inboundRequests.incSuccesses(diagAddr);
+		}
+		return true;
+	    } else {
+		// Give the request another chance
+		if (Math.random() * (overloadHigh - overloadLow) + overloadLow < load) {
+		    if (inboundRequests != null) {
+			inboundRequests.incSuccesses(diagAddr);
+		    }
+		    return true;
+		} 
 	    }
-	    return true;
-	}
+	    return false;
+	}	    
+
+	// Node is seriously loaded
+        if (load < 1) {
+	    if ((ft.contains(searchKey) || ds.contains(searchKey))) {
+		if (Math.random() * (1 - overloadHigh) + overloadHigh < load) {
+		    if (inboundRequests != null) {
+			inboundRequests.incSuccesses(diagAddr);
+		    }
+		    return true;
+		} 
+	    }
+	}	    
 
         // Node is overloaded
         return false;
diff -ur freenet-6190/src/freenet/node/Node.java freenet/src/freenet/node/Node.java
--- freenet-6190/src/freenet/node/Node.java	2003-09-10 23:20:56.000000000 +0200
+++ freenet/src/freenet/node/Node.java	2003-09-10 23:52:34.000000000 +0200
@@ -2474,41 +2474,51 @@
      *
      **/
     public final float estimatedLoad() {
-	double ret;
+	double spare = 1;
 
         int maximumThreads = threadFactory.maximumThreads();
 
-	if (maximumThreads <= 0) 
-	    ret = 0;
-	else 
-	    ret = (double)activeJobs() / (double)maximumThreads;
-	
+	if (maximumThreads > 0) {
+	    // This should be *=, but we know that spare is 1 here
+	    // It is assumed that 25% of the max. threads are just background tasks
+	    // which do not contribute significantly to the load
+	    spare = 1.25 * (1 - (double)activeJobs() / (double)maximumThreads);
+	    if (spare > 1) {
+		spare = 1;
+	    } else if (spare < 0) {
+		spare = 0;
+	    }
+	}
+
         if (diagnostics != null && Main.doRequestTriageByDelay) {
             double delay = diagnostics.getValue("routingTime",
 						Diagnostics.MINUTE,
 						Diagnostics.MEAN_VALUE);
-            delay = overloadLow + 
-		(1-overloadLow) * (delay - requestDelayCutoff) / 
-		(successfulDelayCutoff - requestDelayCutoff);
-            if (delay > overloadLow && ret < delay) ret = delay;
-        }
+	    if (delay > successfulDelayCutoff) {
+		spare = 0;
+	    } else if (delay > requestDelayCutoff) {
+		spare *= 1d - (delay - requestDelayCutoff) / (successfulDelayCutoff - requestDelayCutoff);
+	    }
 	
+        }
+
  	if (diagnostics != null && logOutputBytes && doOutLimitCutoff &&
  	    obw != null) {
  	    double sent = diagnostics.getValue("outputBytes",
  					       Diagnostics.MINUTE,
  					       Diagnostics.COUNT_CHANGE);
-	    int limit = (int)(outputBandwidthLimit /* * lowLevelBWLimitFudgeFactor*/ * 60);
-	    if(sent > (double)(outLimitCutoff * limit)) {
-		return 1.0f;
+	    
+	    double limit = outputBandwidthLimit * outLimitCutoff * 60;
+	    if ( sent > limit ) {
+		spare = 0;
+	    } else {
+		spare *= 1d - (sent / limit);
 	    }
 	}
-	
-        if (ret > 1.0f) {
-            return 1.0f;
-        }
-	
-	long now = System.currentTimeMillis();
+
+        return (float)(1f-spare);
+
+//	long now = System.currentTimeMillis();
 // 	if(doCPULoad && File.separator.equals("/")) {
 // 	    if(now - lastCPULoadEstimateTime > 1000) {
 // 		try {
@@ -2532,10 +2542,9 @@
 // 	}
 // 	float f = ((float)lastCPULoadEstimate)/100.0F;
 // 	if(f > ret) ret = f;
-	
-        return (float)ret;
+// 	return (float)ret;
     }
-    
+ 
     /**
      * Hook for rate limiting.
      */
_______________________________________________
Devl mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to