Skip to content

Instantly share code, notes, and snippets.

@smerritt
Created September 13, 2013 21:31
Show Gist options
  • Save smerritt/6556345 to your computer and use it in GitHub Desktop.
Save smerritt/6556345 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Make some big rings for testing. Doesn't do command-line arg parsing or
# anything fancy; just go change the hard-coded constants. It's not like
# you're going to run this more than a few times before tossing it out.
import os
import subprocess
# clean up from previous runs, if any
try:
os.unlink('big.builder')
except OSError:
pass
subprocess.check_call('swift-ring-builder big.builder create 18 3 1'.split())
add_values = []
for region in xrange(1, 2):
for zone in xrange(1, 6):
for last_octet in xrange(1, 21):
for drive in ('sda', 'sdb', 'sdc', 'sdd', 'sde', 'sdf',
'sdg', 'sdh', 'sdi', 'sdj', 'sdk', 'sdl'):
add_values.append('r%dz%d-10.%d.%d.%d:6000/%s' % (
region, zone, region, zone, last_octet, drive))
BATCH_SIZE = 250
while add_values:
this_batch = add_values[:BATCH_SIZE]
add_values = add_values[BATCH_SIZE:]
cmd = ['swift-ring-builder', 'big.builder', 'add']
for av in this_batch:
cmd.append(av)
cmd.append('3000')
subprocess.check_call(cmd)
subprocess.check_call(['swift-ring-builder', 'big.builder', 'rebalance'])
#!/usr/bin/python
#
# Test ring used:
# 1 region
# 5 zones
# 20 nodes/zone
# 12 drives/node
# --> Total: 1200 devices
#
# Runtime with this patch: ~0.13s, average of 3 trials (remember we do this for 5000 different partitions)
# Runtime with master(5650bdb): 1134s, once (I got bored waiting for it; I'm not doing it twice more)
from swift.common.ring import Ring
from time import time
ring = Ring('big.ring.gz')
stime = time()
for i in xrange(5000):
it = ring.get_more_nodes(i)
for _ in xrange(6):
it.next()
print 'took: %s' % (time() - stime)
#!/usr/bin/python
#
# Test ring used:
# 4 regions
# 5 zones/region
# 20 nodes/zone
# 12 drives/node
# --> Total: 4800 devices
#
# Runtime with this patch: 0.57s (average of 3 trials)
# Runtime with master(5650bdb): 14.7s (average of 3 trials)
from swift.common.ring import Ring
from time import time
ring = Ring('big.ring.gz')
stime = time()
for i in xrange(50):
list(ring.get_more_nodes(i))
print 'took: %s' % (time() - stime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment