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

Modified Files:
        Node.java FailureTable.java 
Log Message:
Make failure table size 20,000 by default. Make Main for FailureTable that tests 
memory usage for a given size failure table.

Index: Node.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Node.java,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -w -r1.235 -r1.236
--- Node.java   31 Oct 2003 19:21:19 -0000      1.235
+++ Node.java   31 Oct 2003 20:51:17 -0000      1.236
@@ -107,7 +107,7 @@
         config.addOption("maxRoutingSteps",     1, 40,   1303);  // to 10 refs
 
         config.addOption("messageStoreSize",    1, 10000,   1350);  // 10000 live 
chains
-        config.addOption("failureTableSize",    1, 2000,  1360); // 2000 failed keys
+        config.addOption("failureTableSize",    1, 20000,  1360); // 20000 failed 
keys - uses ~ 2.7MB
         config.addOption("failureTableTime",    1, 1800000l, 1361); // 30 min
     
         // ARK stuff

Index: FailureTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/FailureTable.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -w -r1.14 -r1.15
--- FailureTable.java   30 Oct 2003 01:34:02 -0000      1.14
+++ FailureTable.java   31 Oct 2003 20:51:18 -0000      1.15
@@ -2,7 +2,9 @@
 
 import java.io.PrintWriter;
 import java.util.Date;
+import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Random;
 
 import freenet.Core;
 import freenet.Key;
@@ -21,9 +23,35 @@
 
     // Todo: make this a test.
 
-//      public static void main(String[] args) {
-//          FailureTable ft = new FailureTable(100, 1800000);
-//          Random r = new Random();
+      public static void main(String[] args) {
+       // Determine memory usage for FT of a given size
+       final int KEYS = 20000;
+          FailureTable ft = new FailureTable(KEYS, 1800000);
+          Random r = new Random();
+          Runtime rt = Runtime.getRuntime();
+          rt.gc();
+          rt.runFinalization();
+          rt.gc();
+          rt.runFinalization();
+          long curUsed = rt.totalMemory() - rt.freeMemory();
+          System.out.println("Using "+curUsed);
+          long startTime = System.currentTimeMillis();
+          for(int i=0;i<KEYS;i++) {
+               byte[] keyval = new byte[20];
+               r.nextBytes(keyval);
+               Key k = new Key(keyval);
+               ft.failedToFind(k, 10, startTime);
+          }
+          long endTime = System.currentTimeMillis();
+          rt.gc();
+          rt.runFinalization();
+          rt.gc();
+          rt.runFinalization();
+          long endUsed = rt.totalMemory() - rt.freeMemory();
+          long diff = endUsed - curUsed;
+          System.out.println("Now used: "+endUsed);
+          System.out.println("FT of "+KEYS+" keys used: "+diff+" bytes");
+          System.out.println("Per key: "+diff/KEYS);
 //          Key[] keys = new Key[16];
 //          for (int i = 0 ; i < 16 ; i++) {
 //              long time = System.currentTimeMillis() - r.nextInt(3600000);
@@ -34,20 +62,20 @@
 //              keys[i] = new Key(keyval);
 //              ft.failedToFind(keys[i], 10, time);
 //          }
-        
+//        
 //          for (Enumeration e = ft.queue.elements() ; e.hasMoreElements() ;) {
 //              System.err.println(e.nextElement());
 //          }
-
+//
 //          System.err.println(ft.shouldFail(keys[0], 1));
 //          ft.checkpoint();
-
+//
 //          System.err.println("---");
-
+//
 //          while (ft.queue.size() > 0) {
 //              System.err.println(ft.queue.pop());
 //          } 
-//      }
+      }
 
     protected int maxSize;
     protected long maxMillis;

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

Reply via email to