misc/simulate_load.py: fix bug in which only K shares were uploaded instead of N, and fix the x axis in place so that successive runs can be compared

This commit is contained in:
Zooko O'Whielacronx 2008-07-12 16:54:29 -07:00
parent f969c5f80e
commit 0e77fe1e92

View File

@ -20,6 +20,9 @@ SERVERS = 40
K = 3 K = 3
N = 10 N = 10
def make_up_a_file_size():
return (2 ** random.randrange(8, 31))
def go(permutedpeerlist): def go(permutedpeerlist):
servers = [ Server() for x in range(SERVERS) ] servers = [ Server() for x in range(SERVERS) ]
servers.sort(cmp=lambda x,y: cmp(x.si, y.si)) servers.sort(cmp=lambda x,y: cmp(x.si, y.si))
@ -27,7 +30,7 @@ def go(permutedpeerlist):
tick = 0 tick = 0
fullservers = 0 fullservers = 0
while True: while True:
nextsharesize = (2 ** random.randrange(8, 31)) / K nextsharesize = make_up_a_file_size() / K
if permutedpeerlist: if permutedpeerlist:
random.shuffle(servers) random.shuffle(servers)
else: else:
@ -36,7 +39,7 @@ def go(permutedpeerlist):
servers = servers[rot:] + servers[:rot] servers = servers[rot:] + servers[:rot]
i = 0 i = 0
sharestoput = K sharestoput = N
while sharestoput: while sharestoput:
server = servers[i] server = servers[i]
if server.used + nextsharesize < server.max: if server.used + nextsharesize < server.max:
@ -62,6 +65,9 @@ def div_ceil(n, d):
DESIRED_COLUMNS = 70 DESIRED_COLUMNS = 70
START_FILES = 137000
STOP_FILES = 144000
def test(permutedpeerlist, iters): 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. # The i'th element of the filledat list is how many servers got full when the i'th file was uploaded.
filledat = [] filledat = []
@ -77,6 +83,10 @@ def test(permutedpeerlist, iters):
startfiles += 1 startfiles += 1
filespercolumn = div_ceil(len(filledat) - startfiles, (DESIRED_COLUMNS - 3)) 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))
# The i'th element of the compressedfilledat list is how many servers got full when the filespercolumn files starting at startfiles + i were uploaded. # 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 = [] compressedfilledat = []
idx = startfiles idx = startfiles