Attached patch implements the above, phase 1 of GJ's overload fix plan,
and a crude approximation to phase 2 (it just accepts the requests in the
most successful bucket, if it's partly overloaded). In need of
optimization, and rather coarse (only 16 buckets). Not yet thoroughly
tested, due to network difficulties.
Future work:
* combine requestDistribution, successDistribution, pSuccess,
binMostSuccessful into a single, more efficient object
* increase to 256 buckets, possibly more, possibly customizable. Keep
smaller numbers of buckets for displaying histograms, and larger numbers
of buckets for overload triage decisions.
* do we want these structures to persist? Do we want them to forget
about hits after a certain time?
* commit after all the above dealt with to minimize disruption due to
resetting datastores etc
* implement phase 2 properly - how to determine Psmin?
* possibly make a histogram out of P(success)
* get CVS write access :)
D'oh.
? noderefs.txt
? src/freenet/.Core.java.swp
? src/freenet/support/KeySizeHistogram.java
Index: src/freenet/Core.java
===
RCS file: /cvsroot/freenet/freenet/src/freenet/Core.java,v
retrieving revision 1.10
diff -u -r1.10 Core.java
--- src/freenet/Core.java 25 Apr 2002 05:02:37 - 1.10
+++ src/freenet/Core.java 23 Jun 2002 01:39:52 -
-211,6 +211,44
/** Distribution of inbound requests over the keyspace. **/
public static KeyHistogram requestDistribution = null;
+/** Distribution of successful inbound requests over the keyspace **/
+public static KeyHistogram successDistribution = null;
+
+/**
+ * Returns the probability of success of a request that would go into
+ * a given bin for stats purposes
+ */ /* fixme: can we optimize these somehow? */
+public static float pSuccess(int bin)
+{
+ int x = requestDistribution.getBin(bin);
+ //if(x == 0) return 0;
+ return ((float)successDistribution.getBin(bin) / (float)x);
+}
+
+/** Returns the most successful bin
+ */
+public static int binMostSuccessful()
+{
+ int ret = -1;
+ float pHighest = 0;
+ for(int i=0;isuccessDistribution.length();i++)
+ {
+ int x = requestDistribution.getBin(i);
+ if(requestDistribution.getBin(i)0)
+ {
+ float p = (float)successDistribution.getBin(i)/(float)x;
+ if(ppHighest ||
+ (p == pHighest ret != -1
+ xrequestDistribution.getBin(ret)))
+ {
+ pHighest = p;
+ ret = i;
+ }
+ };
+ }
+ return ret;
+}
+
/**
* Sets the logging object to be used for logging messages
* param log a Logger object that will log messages to an output stream.
Index: src/freenet/client/http/NodeStatusServlet.java
===
RCS file: /cvsroot/freenet/freenet/src/freenet/client/http/NodeStatusServlet.java,v
retrieving revision 1.26
diff -u -r1.26 NodeStatusServlet.java
--- src/freenet/client/http/NodeStatusServlet.java 30 May 2002 23:56:51 -
1.26
+++ src/freenet/client/http/NodeStatusServlet.java 23 Jun 2002 01:39:56 -
-41,6 +41,7
import freenet.support.StringMap;
import freenet.support.SimpleStringMap;
import freenet.support.KeyHistogram;
+import freenet.support.KeySizeHistogram;
import freenet.support.graph.BitmapEncoder;
/*
-141,6 +142,11
return;
}
+ if (uri.endsWith(ds_size_histogram.txt)) {
+ sendDSSizeHistogram(resp, false);
+ return;
+ };
+
if (uri.endsWith(inbound_request_histogram.txt)) {
int[] bins = null;
if (node.requestDistribution != null) {
-149,10 +155,21
sendKeyHistogram(resp, false, bins,
Histogram of requested keys.,
This count has nothing to do with keys in your
datastore,
- MSG_NO_REQUEST_DIST);
+ MSG_NO_REQUEST_DIST, keys, false);
return;
}
+ if(uri.endsWith(inbound_success_histogram.txt)) {
+ int [] bins = null;
+ if (node.successDistribution != null) {
+ bins = node.successDistribution.getBins();
+ }
+ sendKeyHistogram(resp, false, bins,
+ Histogram of successfully requested keys.,
+ This count has nothing to do with keys in your
+datastore,
+ MSG_NO_REQUEST_DIST, keys, false);
+ return;
+ }
if (uri.endsWith(key_histogram_data.txt)) {
sendRTHistogram(resp, true);