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

Modified Files:
        LoadStats.java Main.java Node.java 
Log Message:
(Version.java) 6214
(LoadStats.java) configurable lsAcceptRatioSamples
  During short interval before local queries / hour
  is known, assume it is equal to global queries / hour.
(Main.java) Pass Node.lsMaxTableSize and Node.lsAcceptRatioSamples
  to LoadStats constructor.
(Node.java) Add configuration options lsAcceptRatioSamples
  and lsMaxTableSize.


Index: LoadStats.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/LoadStats.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- LoadStats.java      26 Sep 2003 09:22:36 -0000      1.28
+++ LoadStats.java      30 Sep 2003 08:02:49 -0000      1.29
@@ -45,16 +45,21 @@
     private final Object timesLock = new Object();
     private long[] times;
     private int timesPos;
-    private short ratio;
+    private int 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.
+    private final int ratioSamples; // was 100.
     
     /**
      * Create a new loadstats object.
-     * @param maxTableSize  The maximum number of peers to store traffic from.
+     * @param table         The DataStoreObject providing load entries.
+     * @param lsMaxTableSize The maximum number of peers to use for calculating
+     *                      global queries/hour. 
+     * @param lsAcceptRatioSamples 
+     *                      Number of query fates saved for acceptRatio, and
+     *                      number of query arrival times for queries/hour calc.
      * @param diag          The node's diagnostics object. A category named
      *                      "Network Load" will be added with the following
      *                      fields:
@@ -67,11 +72,15 @@
      * @param parent        The category to make the parent of the 
      *                      new category, or null to leave it at the top.
      */
-    public LoadStats(DataObjectStore table, int maxTableSize, Diagnostics diag,
+    public LoadStats(DataObjectStore table, 
+                    int lsMaxTableSize, 
+                    int lsAcceptRatioSamples,
+                     Diagnostics diag,
                      DiagnosticsCategory parent, 
                     double defaultResetProbability) throws IOException {
         this.table = table;
-        this.maxTableSize = maxTableSize;
+       this.maxTableSize = lsMaxTableSize;
+       this.ratioSamples = lsAcceptRatioSamples;
         this.diag = diag;
        this.defaultResetProbability = defaultResetProbability;
 
@@ -324,25 +333,60 @@
                       (total * total) / (n * (n - 1.0)));
         
         double local = localQueryTraffic();
-        double relProb = local == 0 ? 1 : Math.min(1, defaultResetProbability
-                                                  * (mean / local));
+       double relProb = local == 0 
+           ? defaultResetProbability // no data, assume local == mean
+           : Math.min(1, defaultResetProbability * (mean / local));
         double acceptRatio;
        int x = 0;
         synchronized (timesLock) {
            x = ratio;
         }
        acceptRatio = ((double)x)/ratioSamples;
+
+       // Probability of resetting the DataSource
+
        // resetProbability = acceptRatio ^ 5 * relProb,
        // with some bounds to avoid degeneration:
        // resetProbability is at least 2%, no more than 50%.
+
+       // Currently, default defaultResetProbability is 0.05.
+
+       // When local is over 2.5 times global, prob is always 2%.
+
+       // When local is 1 times global, acceptRatio must
+       // be over 0.80 for prob to exceed 2%, and it only
+       // rises to 5% (i.e. defaultResetProbability) at 1.0
+
+       // When local is 1/10 of global, prob starts rising
+       // around 0.5 acceptance and reaches 50% at 1.0.
+
+
+       // resetProbability as function of local/global and acceptRatio,
+       // assuming defaultResetProbability = 0.05.
+       //
+       //  local    accepted Query Ratio
+       // ------  0.0 0.2 0.4 0.6   0.8   1.0
+       // global
+       //  0.1    2%  2%  2%  3.9% 16.4% 50.0%
+       //  0.3    2%  2%  2%  2%    5.5% 16.7%
+       //  0.5    2%  2%  2%  2%    3.3% 10.0%
+       //  0.7    2%  2%  2%  2%    2.3%  7.1%
+       //  0.9    2%  2%  2%  2%    2%    5.6%
+       //  1.1    2%  2%  2%  2%    2%    4.5%
+       //  1.3    2%  2%  2%  2%    2%    3.8%
+       //  1.5    2%  2%  2%  2%    2%    3.3%
+       //  1.7    2%  2%  2%  2%    2%    2.9%
+       //  1.9    2%  2%  2%  2%    2%    2.6%
+       //  2.1    2%  2%  2%  2%    2%    2.4%
+       //  2.3    2%  2%  2%  2%    2%    2.2%
+       //  2.5    2%  2%  2%  2%    2%    2%
+
         double prob = Math.min(Math.max((Double.isNaN(acceptRatio) ? 1 : 
                                          Math.pow(acceptRatio, 5)) 
                                         * relProb,
                                         0.02),
                                0.5);
-        
 
-        
         diag.occurrenceContinuous("globalQueryTrafficMean", mean);
         diag.occurrenceContinuous("globalQueryTrafficMedian", median);
         diag.occurrenceContinuous("globalQueryTrafficDeviation", deviation);
@@ -467,11 +511,3 @@
     }
 
 }
-
-
-
-
-
-
-
-

Index: Main.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Main.java,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -r1.261 -r1.262
--- Main.java   18 Sep 2003 17:48:09 -0000      1.261
+++ Main.java   30 Sep 2003 08:02:49 -0000      1.262
@@ -838,7 +838,9 @@
                                System.exit(27);
                        }
            
-            LoadStats loadStats = new LoadStats(lsNodes, 100, Core.diagnostics,
+            LoadStats loadStats = new LoadStats(lsNodes, Node.lsMaxTableSize,
+                                                                                      
         Node.lsAcceptRatioSamples,
+                                                                                      
         Core.diagnostics,
                                                 null, 
                                                                                       
         Node.defaultResetProbability);
                        

Index: Node.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Node.java,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -r1.211 -r1.212
--- Node.java   18 Sep 2003 17:48:09 -0000      1.211
+++ Node.java   30 Sep 2003 08:02:50 -0000      1.212
@@ -214,12 +214,16 @@
 //     config.addOption("doCPULoad",1,false,3264);
        config.addOption("sendingQueueLength",1,256,3265);
        config.addOption("sendingQueueBytes",1,1492*8,3266);
-       config.addOption("defaultResetProbability",1, 0.05, 3557);
        
        // WatchMe options.
        config.addOption("watchme", 1, false, 3541);
         config.addOption("watchmeRetries", 1, 3, 3542);
        
+       // LoadStats options.
+       config.addOption("defaultResetProbability", 1, 0.05, 3557);
+       config.addOption("lsMaxTableSize", 1, 100, 3558);
+       config.addOption("lsAcceptRatioSamples", 1, 500, 3559);
+
        // Forward Error Correction (FEC) options
        config.addOption("FECTempDir", 1, "", 3600);
         config.addOption("FECInstanceCacheSize", 1, 1, 3610);
@@ -1186,7 +1190,19 @@
        config.argDesc   ("defaultResetProbability", "<probability>");
        config.shortDesc ("defaultResetProbability", "Default probability of resetting 
the DataSource");
        config.longDesc  ("defaultResetProbability", "The node will have this 
probability, on average (it varies according to load unless you set doLoadBalance=no), 
of resetting the datasource. Increase this to get more load, reduce it to get less 
load.");
-       
+
+       // lsMaxTableSize
+       config.setExpert ("lsMaxTableSize", true);
+       config.argDesc   ("lsMaxTableSize", "<positive integer>");
+       config.shortDesc ("lsMaxTableSize", "Maximum number of peers to save 
queries/hour from");
+       config.longDesc  ("lsMaxTableSize", "LoadStats: Global queries/hour is 
calculated from at most this number of peers.");
+
+       // lsAcceptRatioSamples
+       config.setExpert ("lsAcceptRatioSamples", true);
+       config.argDesc   ("lsAcceptRatioSamples", "<positive integer>");
+       config.shortDesc ("lsAcceptRatioSamples", "Number of query arrival time and 
accepted/rejected status entries.");
+       config.longDesc  ("lsAcceptRatioSamples", "LoadStats: Current proportion of 
requests being accepted is calculated from the fate of this number of recent requests. 
 The local queries/hour is calculated from the time it took for this number of queries 
to arrive.");
+
         // logOutboundContacts
         config.setExpert ("logOutboundContacts",true);
         config.argDesc   ("logOutboundContacts","true/false");
@@ -1741,6 +1757,8 @@
     static public int requestDelayCutoff;
     static public int successfulDelayCutoff;
     static public double defaultResetProbability;
+    static public int lsMaxTableSize;
+    static public int lsAcceptRatioSamples;
     static public boolean doOutLimitCutoff;
     static public boolean doOutLimitConnectCutoff;
     static public float outLimitCutoff;
@@ -2069,6 +2087,8 @@
        requestDelayCutoff = params.getInt("requestDelayCutoff");
        successfulDelayCutoff = params.getInt("successfulDelayCutoff");
        defaultResetProbability = params.getDouble("defaultResetProbability");
+       lsMaxTableSize = params.getInt("lsMaxTableSize");
+       lsAcceptRatioSamples = params.getInt("lsAcceptRatioSamples");
        doOutLimitCutoff = params.getBoolean("doOutLimitCutoff");
        outLimitCutoff = params.getFloat("outLimitCutoff");
        doOutLimitConnectCutoff = params.getBoolean("doOutLimitConnectCutoff");

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

Reply via email to