]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
simulate_load: put it in friendnet mode and print out a sum of doubled shares
authorZooko O'Whielacronx <zooko@zooko.com>
Mon, 21 Jul 2008 21:11:06 +0000 (14:11 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Mon, 21 Jul 2008 21:11:06 +0000 (14:11 -0700)
misc/simulate_load.py

index a39fbe1618f795f80a754fac40844d0e08d1953e..de7437c713d9424c53e38450d381b51444b3c3ec 100644 (file)
@@ -3,11 +3,13 @@
 
 import random
 
+SERVER_CAPACITY = 10**12
+
 class Server:
     def __init__(self):
         self.si = random.randrange(0, 2**31)
         self.used = 0
-        self.max = 2**40
+        self.max = SERVER_CAPACITY
         self.full_at_tick = None
 
     def __repr__(self):
@@ -16,7 +18,7 @@ class Server:
         else:
             return "<%s %s>" % (self.__class__.__name__, self.si)
 
-SERVERS = 40
+SERVERS = 4
 K = 3
 N = 10
 
@@ -27,6 +29,7 @@ def go(permutedpeerlist):
     servers = [ Server() for x in range(SERVERS) ]
     servers.sort(cmp=lambda x,y: cmp(x.si, y.si))
 
+    doubled_up_shares = 0
     tick = 0
     fullservers = 0
     while True:
@@ -39,21 +42,27 @@ def go(permutedpeerlist):
             servers = servers[rot:] + servers[:rot]
 
         i = 0
+        wrapped = False
         sharestoput = N
         while sharestoput:
             server = servers[i]
             if server.used + nextsharesize < server.max:
                 server.used += nextsharesize
                 sharestoput -= 1
+                if wrapped:
+                    doubled_up_shares += 1
             else:
                 if server.full_at_tick is None:
                     server.full_at_tick = tick
                     fullservers += 1
                     if fullservers == len(servers):
                         # print "Couldn't place share -- all servers full.  Stopping."
-                        return servers
+                        return (servers, doubled_up_shares)
 
-            i = (i + 1) % len(servers)
+            i += 1
+            if i == len(servers):
+                wrapped = True
+                i = 0
 
         tick += 1
 
@@ -72,7 +81,8 @@ def test(permutedpeerlist, iters):
     # The i'th element of the filledat list is how many servers got full when the i'th file was uploaded.
     filledat = []
     for test in range(iters):
-        servers = go(permutedpeerlist)
+        (servers, doubled_up_shares) = go(permutedpeerlist)
+        print "doubled_up_shares: ", doubled_up_shares
         for server in servers:
             fidx = server.full_at_tick
             filledat.extend([0]*(fidx-len(filledat)+1))
@@ -84,8 +94,8 @@ def test(permutedpeerlist, iters):
     filespercolumn = div_ceil(len(filledat) - startfiles, (DESIRED_COLUMNS - 3))
 
     # to make comparisons between runs line up:
-    startfiles = START_FILES
-    filespercolumn = div_ceil(STOP_FILES - startfiles, (DESIRED_COLUMNS - 3))
+    startfiles = START_FILES
+    filespercolumn = div_ceil(STOP_FILES - startfiles, (DESIRED_COLUMNS - 3))
 
     # The i'th element of the compressedfilledat list is how many servers got full when the filespercolumn files starting at startfiles + i were uploaded.
     compressedfilledat = []