Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
adding the perf testing scripts to the repo
  • Loading branch information
BuzzTroll committed Sep 10, 2010
1 parent 687b290 commit ee7a9e1
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lantorrent/etc/lt.sql
Expand Up @@ -8,7 +8,7 @@ create table requests(
port INTEGER NOT NULL DEFAULT 2893,
state INTEGER DEFAULT 0,
message TEXT,
entry_time DATETIME,
entry_time TIMESTAMP,
attempt_count INTEGER DEFAULT 0,
UNIQUE(hostname, port, dst_filename)
);
Expand Down
49 changes: 49 additions & 0 deletions lantorrent/perf/boto_many.py
@@ -0,0 +1,49 @@
#!/usr/bin/python


import sys
import string
import random
import os
import sys
import sys
import ConfigParser
from ConfigParser import SafeConfigParser
import time
import tempfile
import traceback
import filecmp
import logging
import shlex
from optparse import SUPPRESS_HELP
import boto
from boto.s3.connection import OrdinaryCallingFormat
from boto.s3.connection import VHostCallingFormat
from boto.s3.connection import SubdomainCallingFormat
from boto.s3.connection import S3Connection
from boto.ec2.connection import EC2Connection


def main(argv=sys.argv[1:]):

host = argv[0]
imagename = argv[1]
count = int(argv[2])

print "setting up ec2 connection"
ec2conn = EC2Connection(s3id, pw, host=host, port=8444, debug=2)
ec2conn.host = host

print "getting a reference to the remote image"
image = ec2conn.get_image(imagename)
print "running %d instances" % (count)
res = image.run(min_count=count, max_count=count)
print "stoping all instances"
res.stop_all()

return 0

if __name__ == "__main__":
rc = main()
sys.exit(rc)

7 changes: 7 additions & 0 deletions lantorrent/perf/cc_tests/cmd.sh
@@ -0,0 +1,7 @@
#!/bin/bash

histdir=`mktemp -d`
cmd="/home/bresnaha/nimbus-cloud-client-016/bin/cloud-client.sh --name lenny-vm.raw --hours .1 --run --history-dir $histdir"
$cmd
rm -rf $histdir

19 changes: 19 additions & 0 deletions lantorrent/perf/cc_tests/counter.sh
@@ -0,0 +1,19 @@
#!/bin/bash

tm_file=$1
cnts="4 8 16 32 64"
trials=4

touch $tm_file
for c in $cnts
do
for i in `seq 1 $trials`
do
echo $i
/usr/bin/time --append -o $tm_file --format "$c %e" ./timer.sh $c
sleep 90
rm -rf /home/bresnaha/nimbus-cloud-client-016/history/*
sleep 90
done
done

14 changes: 14 additions & 0 deletions lantorrent/perf/cc_tests/timer.sh
@@ -0,0 +1,14 @@
#!/bin/bash

cmd="./cmd.sh"
max=$1
pid_list=""
for i in `seq 1 $max`
do
touch run.log
$cmd | tee -a run.log &
pid_list="$pid_list $!"
done

wait

33 changes: 18 additions & 15 deletions lantorrent/pylantorrent/daemon.py
Expand Up @@ -14,7 +14,7 @@

def getrows(con):
c = con.cursor()
tm = datetime.datetime.now() - datetime.timedelta(0, 5)
tm = datetime.datetime.now() - datetime.timedelta(0, 10)
s = "select distinct src_filename from requests where state = 0 and attempt_count < 3 and entry_time < ? order by entry_time limit 1"
data = (tm, )
c.execute(s, data)
Expand All @@ -26,19 +26,22 @@ def getrows(con):
# from the db. better to grab any that came in since the initial
# select
con.commit()

s = "select max(entry_time) from requests where src_filename = ? and state = 0 and attempt_count < 3"
data = (src_file, )
done = False
while not done:
c.execute(s, data)
row = c.fetchone()
con.commit()
td = datetime.datetime.now() - datetime.timedelta(0, 2)
if row[0] < td:
done = True
else:
time.sleep(0.1)
pylantorrent.log(logging.INFO, "selected rows with fname %s" % (src_file))

# need to find a way to determine that nothing new has been added for this
# file recently
#s = 'select max(entry_time) as "e [timestamp]" from requests where src_filename = ? and state = 0 and attempt_count < 3'
#data = (src_file, )
#done = False
#while not done:
# c.execute(s, data)
# row = c.fetchone()
# con.commit()
# td = datetime.datetime.now() - datetime.timedelta(0, 2)
# if row[0] < td:
# done = True
# else:
# time.sleep(0.1)

s = "select hostname,port,src_filename,dst_filename,rid from requests where src_filename = ? and state = 0 and attempt_count < 3 order by hostname,port"
data = (src_file, )
Expand Down Expand Up @@ -148,7 +151,7 @@ def main(argv=sys.argv[1:]):
con_str = pylantorrent.config.dbfile
now = datetime.datetime.now()
#con = sqlite3.connect(con_str, isolation_level="EXCLUSIVE")
con = sqlite3.connect(con_str)
con = sqlite3.connect(con_str, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)

done = False
while not done:
Expand Down

0 comments on commit ee7a9e1

Please sign in to comment.