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

Modified Files:
        LoadStats.java 
Log Message:
(LoadStats.java) use 200 samples for accept ratio and 
  requests/hour.
(LRUQueue.java) fix an NPE.
(QThreadFactory.java) fix bugs, simplify.  
  Changes since 1.28 really do reduce lock contention.
  added trailing blanks on certain lines so that
  emacs ediff vs. 1.28 does not lose sync.
(ReadSelectorLoop.java) fix typo in comment.
(Version.java) 6208


Index: LoadStats.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/LoadStats.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- LoadStats.java      15 Jul 2003 00:50:37 -0000      1.27
+++ LoadStats.java      26 Sep 2003 09:22:36 -0000      1.28
@@ -46,11 +46,16 @@
     private long[] times;
     private int timesPos;
     private short ratio;
+    // The traffic numbers (queries/hour) are calculated from the
+    // time it took for the last ratioSamples queries to arrive.
+    // Also, the acceptedQ/totalQ ratio is calculated from
+    // this number of samples.
+    private final short ratioSamples = 200; // was 100.
     
     /**
      * Create a new loadstats object.
      * @param maxTableSize  The maximum number of peers to store traffic from.
-     * @param diag          The nodes diagnostics object. A category named
+     * @param diag          The node's diagnostics object. A category named
      *                      "Network Load" will be added with the following
      *                      fields:
      *                      Binomial          localQueryTraffic
@@ -70,9 +75,9 @@
         this.diag = diag;
        this.defaultResetProbability = defaultResetProbability;
 
-        this.times = new long[100];
+        this.times = new long[ratioSamples];
         this.timesPos = 0;
-        this.ratio = 100;
+        this.ratio = ratioSamples;
 
         for (Enumeration e = table.keys(true) ; e.hasMoreElements(); ) {
             LoadEntry le = getLoadEntry((FileNumber) e.nextElement());
@@ -162,10 +167,10 @@
            if (lru.size() >= maxTableSize)
                insufficientData = false;
            if((!insufficientData) && old) {
-               Core.logger.log(this, "Doing checkpoint, passed 100 queries",
+               Core.logger.log(this, "Doing checkpoint, passed " + maxTableSize + " 
queries",
                                Logger.MINOR);
                checkpoint();
-               Core.logger.log(this, "Done checkpoint, passed 100 queries",
+               Core.logger.log(this, "Done checkpoint, passed " + maxTableSize + " 
queries",
                                Logger.MINOR);
            }
         } catch (IOException e) {
@@ -188,8 +193,16 @@
             return 0;
         if (time < 0)
             time = time * -1;
-        
-        return (3600 * 1000 * 100.0) / 
+
+        // second millisecond  query
+        // ------ ----------- --------
+        //  hour    second    interval     query
+        // --------------------------- ==> -----
+        //         millisecond             hour
+        //         -----------
+        //          interval
+
+        return (3600.0 * 1000 * ratioSamples) / 
             ((double) (System.currentTimeMillis() - time));
     }
 
@@ -318,9 +331,10 @@
         synchronized (timesLock) {
            x = ratio;
         }
-       acceptRatio = ((double)x)/100;
-        // acceptRation ^ 2 * relProb with some bounds to avoid
-       // degeneration.
+       acceptRatio = ((double)x)/ratioSamples;
+       // resetProbability = acceptRatio ^ 5 * relProb,
+       // with some bounds to avoid degeneration:
+       // resetProbability is at least 2%, no more than 50%.
         double prob = Math.min(Math.max((Double.isNaN(acceptRatio) ? 1 : 
                                          Math.pow(acceptRatio, 5)) 
                                         * relProb,
@@ -380,7 +394,7 @@
        synchronized(timesLock) {
            x = ratio;
        }
-       acceptRatio = ((double)x)/100;
+       acceptRatio = ((double)x)/ratioSamples;
        pw.println("<li> Current proportion of requests being accepted: "+
                   acceptRatio + "</li>");
         pw.println("</ul>");

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

Reply via email to