Index: /u/drkp/sandbox/txcache/src/pincushion/pincushion.c =================================================================== --- /u/drkp/sandbox/txcache/src/pincushion/pincushion.c (revision 3562) +++ /u/drkp/sandbox/txcache/src/pincushion/pincushion.c (working copy) @@ -185,7 +185,7 @@ Pincushion_Setup(server_t *server) { //set up database connection - DB_Init("dbname=rubis user=cecchet"); + DB_Init("dbname=rubis user=cecchet host=farm14.csail.mit.edu"); PT_Init(); RPCS_RegisterHandler(server, PINCUSHION_REQ_REQUEST, HandleRequest); Index: /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/run-bench.py =================================================================== --- /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/run-bench.py (revision 3562) +++ /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/run-bench.py (working copy) @@ -16,11 +16,13 @@ # 3000, 3250, 3500, 3750, # 4000, 4250, 4500, 4750, 5000, 5250, 5500, # 5750, 6000, 6250, 6500, 6750, 7000, 7250, 7500] -STDWARMUP=[500,1000,2000] +STDWARMUP=[2000] CACHEHOSTS=[("farm12.csail.mit.edu", 16001), - ("farm12.csail.mit.edu", 16002)] + ("farm13.csail.mit.edu", 16001)] PINCUSHIONHOST=(CACHEHOSTS[0][0], 16000) CACHESIZE="512M" +STDPINPOLICY="latest bounded pin with variety (5 secs)" +STDFRESHNESS=30.0 import sys, os, re, time, glob @@ -36,12 +38,14 @@ def vacuum(): os.system("vacuumdb -zf -h %s -U %s %s" % (DBHOST, DBUSER, DBNAME)) + os.system("echo REINDEX DATABASE %s | psql -h %s -U %s %s" % + (DBNAME, DBHOST, DBUSER, DBNAME)) def flushCache(): for x in set([y[0] for y in CACHEHOSTS] + WEBHOSTS + [DBHOST]): os.system("ssh %s %s/bench/flush_cache %d" % (x, RUBISPATH, MEMSIZE)) -def startCache(): +def startCache(config): print "Rsyncing cache" for host,port in CACHEHOSTS: os.system("rsync -a ~/sandbox %s:" % (host)) @@ -56,10 +60,16 @@ # Generate nodes.txt nodesTxt = file(os.path.join(RUBISPATH, "PHP", "nodes.txt"), "w") + nodesTxt.write(config.pinPolicy + "\n") nodesTxt.write("%s:%d\n" % (PINCUSHIONHOST[0], PINCUSHIONHOST[1])) for host, port in CACHEHOSTS: nodesTxt.write("%s:%d\n" % (host, port)) nodesTxt.close() + + # Generate freshness.php + freshnessPHP = file(os.path.join(RUBISPATH, "PHP", "freshness.php"), "w") + freshnessPHP.write("" % + (config.freshnessReq)) def stopCache(): print "Stopping cache" @@ -84,11 +94,13 @@ for client in set(REMOTECLIENTHOSTS + WEBHOSTS): os.system("rsync -a ~/sandbox %s:" % (client)) stopApache() - for host in WEBHOSTS: - os.system("ssh -t %s sudo find /tmp/clog -delete" % (host)) - os.system("ssh -t %s sudo find /tmp/stats -delete" % (host)) - for host, port in CACHEHOSTS: - os.system("%s -c %s:%d" % (SERVERSTATSPATH, host, port)) + if config.useCache: + for host in WEBHOSTS: + os.system("ssh -t %s sudo find /tmp/clog -delete" % (host)) + os.system("ssh -t %s sudo find /tmp/stats -delete" % (host)) + for host, port in CACHEHOSTS: + os.system("%s -c %s:%d" % (SERVERSTATSPATH, host, port)) + vacuum() startApache() # Run @@ -111,19 +123,20 @@ os.system("scp %s:%s/data/postgresql.conf %s/bench/%s/info/" % (DBHOST, config.pgsql, RUBISPATH, benchDir)) os.system("ssh %s sudo chmod 700 %s/data" % (DBHOST, config.pgsql)) - os.system("cp ~/server*.log ~/pincushion.log %s/bench/%s/info/" % - (RUBISPATH, benchDir)) - for host in WEBHOSTS: - os.system("rsync -a %s:/tmp/clog/ %s/bench/%s/info/clog-%s" % - (host, RUBISPATH, benchDir, host)) - os.system("rsync -a %s:/tmp/stats/ %s/bench/%s/info/stats-%s" % - (host, RUBISPATH, benchDir, host)) - os.system("%s %s/bench/%s/info/stats-*/* > %s/bench/%s/info/latency.txt 2>&1" % - (SUMLATENCIESPATH, RUBISPATH, benchDir, RUBISPATH, benchDir)) - for host, port in CACHEHOSTS: - os.system("%s %s:%d > %s/bench/%s/info/cachestats.%s.%d" % - (SERVERSTATSPATH, host, port, - RUBISPATH, benchDir, host, port)) + if config.useCache: + os.system("cp ~/server*.log ~/pincushion.log %s/bench/%s/info/" % + (RUBISPATH, benchDir)) + for host in WEBHOSTS: + os.system("rsync -a %s:/tmp/clog/ %s/bench/%s/info/clog-%s" % + (host, RUBISPATH, benchDir, host)) + os.system("rsync -a %s:/tmp/stats/ %s/bench/%s/info/stats-%s" % + (host, RUBISPATH, benchDir, host)) + os.system("%s %s/bench/%s/info/stats-*/* > %s/bench/%s/info/latency.txt 2>&1" % + (SUMLATENCIESPATH, RUBISPATH, benchDir, RUBISPATH, benchDir)) + for host, port in CACHEHOSTS: + os.system("%s %s:%d > %s/bench/%s/info/cachestats.%s.%d" % + (SERVERSTATSPATH, host, port, + RUBISPATH, benchDir, host, port)) return BenchResult(findLatestBench()) def findLatestBench(): @@ -179,11 +192,121 @@ " ".join([str(x) for x in self.statlineSummary])) -def runSeries(config, numClients, args=""): +def runSeries(config, numClients): results = [] for n in numClients: - results.append(runBench(config, n, args)) + results.append(runBench(config, n, config.makePropertiesArgs)) return results + +def runSeriesDynamic(config, maxRuns, startClients, increment, afterPeak): + results = [] + n = startClients + stopAfterPeak = afterPeak + + while True: + lastResult = runBench(config, n, config.makePropertiesArgs) + results.append(lastResult) + + print "Run ", len(results) + print "Last throughput:", lastResult.avgThroughput + if len(results) >= maxRuns: + print "Stopping -- reached maxRuns:", maxRuns + return results + if len(results) >= stopAfterPeak: + print "Stopping -- reached stopAfterPeak:", stopAfterPeak + return results + + maxThroughput = max([x.avgThroughput for x in results]) + print "Max throughput:", maxThroughput + if lastResult.avgThroughput == maxThroughput: + stopAfterPeak = len(results) + afterPeak + print "Still at peak -- resetting stopAfterPeak to", stopAfterPeak + else: + print "Past peak. Will stop at ", stopAfterPeak + + n += increment + +def runSeriesFindPeak(config, startClients, increment, tolerance): + results = [] + n = startClients + peakThroughput = 0 + lastThroughput = 0 + leftBound = 0 + rightBound = 0 + cache = {} + + # Find peak with a coarse scan + while lastThroughput == peakThroughput: + print "In fast/coarse scan. Running", n + lastResult = runBench(config, n, config.makePropertiesArgs) + results.append(lastResult) + lastThroughput = lastResult.avgThroughput + cache[n] = lastThroughput + print "In fast/coarse scan. Run", len(results) + print "n =", n, "(linear throughput would be:", 0.165*n, ")" + print "Last throughput:", lastThroughput + print "Last latency:", lastResult.avgLatency + if (lastThroughput >= peakThroughput): + peakThroughput = lastThroughput + leftBound = n + rightBound = n + n += increment + + + leftBound -= increment + n = leftBound + if (n < startClients): + print "ERROR: coarse scan increment too high!" + return results + + print "Fast/coarse scan done. Starting slow/fine scan from", n, "to", rightBound + + # Find peak again with a fine-grained scan + peakThroughput = 0 + lastThroughput = 0 + while n <= rightBound: + try: + lastThroughput = cache[n] + print "In slow/fine scan. Reusing cached value:", n, "=>", cache[n] + except KeyError: + print "In slow/fine scan. Running:", n, + lastResult = runBench(config, n, config.makePropertiesArgs) + results.append(lastResult) + lastThroughput = lastResult.avgThroughput + print "In slow/fine scan. Run", len(results) + print "n =", n, "(linear throughput would be:", 0.165*n, ")" + print "Last throughput:", lastThroughput + print "Last latency:", lastResult.avgLatency + if (lastThroughput >= peakThroughput): + peakThroughput = lastThroughput + n += tolerance + + print "Found peak at ", peakThroughput + + + # print "Peak throughput for scanning phase:", peakThroughput + # print "Starting binary search over", leftBound, rightBound + + # while (rightBound - leftBound) > tolerance: + # print "Binary search:", leftBound, rightBound + # n = (rightBound + leftBound)/2 + # print "Trying", n + # lastResult = runBench(config, n, config.makePropertiesArgs) + # results.append(lastResult) + # lastThroughput = lastResult.avgThroughput + # print "Run", len(results) + # print "Last throughput:", lastThroughput + # if (lastThroughput >= peakThroughput): + # print "New peak throughput" + # peakThroughput = lastThroughput + # leftBound = n + # else: + # print "Less than peak throughput" + # rightBound = n + + # print "Binary search done -- peak lies in", leftBound, rightBound + # return results + def printResults(results): for x in results: @@ -195,7 +318,8 @@ def makeResultsDirectory(results, resdirpath): os.mkdir(resdirpath) - dumpResults(results, os.path.join(resdirpath, "results.txt")) + dumpResults(results, os.path.join(resdirpath, + os.path.basename(resdirpath)+".txt")) for res in results: os.symlink(os.path.join(RUBISPATH, "bench", res.name), os.path.join(resdirpath, str(res.numClients)+"-bench")) @@ -207,7 +331,9 @@ def __init__(self, name, pgsql, reloadDB=True, vacuum=True, flushCache=True, warmup=STDWARMUP, makePropertiesArgs="medium mediumsize", - useCache=False, doItAnyway=False, microCache=False): + useCache=False, doItAnyway=False, microCache=False, + freshnessReq=STDFRESHNESS, pinPolicy=STDPINPOLICY, + runSeriesFn=(lambda x : runSeries(x, NUMCLIENTS))): self.name = name self.pgsql = pgsql self.reloadDB = reloadDB @@ -218,6 +344,9 @@ self.useCache = useCache self.microCache = microCache self.doItAnyway = doItAnyway + self.freshnessReq = freshnessReq + self.pinPolicy = pinPolicy + self.runSeriesFn = runSeriesFn if self.doItAnyway: self.makePropertiesArgs += " doitanyway" self.useCache = True @@ -234,20 +363,27 @@ self.stop() def setup(self): + os.system("killall java ; ssh farm6 killall java; ssh farm12 killall server; ssh farm13 killall server; ssh farm14 killall pincushion;ssh farm12 killall pincushion;ssh farm13 sudo /etc/init.d/apache2 stop;ssh farm12 sudo /etc/init.d/apache2 stop") # XXX + time.sleep(1) + startApache() startDB(self.pgsql) if self.reloadDB: reloadDB(self.pgsql) - if self.vacuum: - vacuum() + # ignore this -- we vacuum between data points now + # if self.vacuum: + # vacuum() if self.flushCache: flushCache() if self.useCache: - startCache() + startCache(self) for x in self.warmup: runBench(self, x, self.makePropertiesArgs) def run(self): - results = runSeries(self, NUMCLIENTS, self.makePropertiesArgs) +# results = runSeriesDynamic(self, 20, +# 2000, 1000, 2) +# results = runSeriesFindPeak(self, 10000, 2000, 500) + self.runSeriesFn(self) printResults(results) makeResultsDirectory(results, ("results/results-"+ time.strftime("%Y%m%d%H%M%S")+ @@ -263,14 +399,17 @@ EXPERIMENTS = [ # ExperimentConfig("mediumdb-stock", "/u/drkp/build/postgresql-8.2.11/obj"), # ExperimentConfig("mediumdb-modified", "/u/drkp/sandbox/txcache/src/pgsql/obj"), -# ExperimentConfig("mediumdb-txcache", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True), -# ExperimentConfig("mediumdb-txcache-microcache", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True, microCache=True), +# ExperimentConfig("mediumdb-txcache-varietypin", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True), +# ExperimentConfig("mediumdb-txcache-jitterpin-microcache", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True, microCache=True, freshnessReq=30, pinPolicy="latest bounded pin with variety (5 to 20 secs)", warmup=[]), + ExperimentConfig("mediumdb-txcache-freshness30", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True, microCache=True, freshnessReq=30, runSeriesFn=(lambda x: runSeriesDynamic(x, 20, 1000, 1000, 3))), + ExperimentConfig("mediumdb-txcache-freshness60", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True, microCache=True, freshnessReq=60, runSeriesFn=(lambda x: runSeriesDynamic(x, 25, 10000, 1000, 1))), + ExperimentConfig("mediumdb-txcache-freshness15", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True, microCache=True, freshnessReq=15, runSeriesFn=(lambda x: runSeriesDynamic(x, 20, 2000, 1000, 1))), + ExperimentConfig("mediumdb-txcache-freshness5", "/u/drkp/sandbox/txcache/src/pgsql/obj", useCache=True, microCache=True, freshnessReq=5, runSeriesFn=(lambda x: runSeriesDynamic(x, 20, 2000, 1000, 1))) # ExperimentConfig("nofsync-txcache-doitanyway", "/u/drkp/sandbox/txcache/src/pgsql/obj", doItAnyway=True, reloadDB=False, vacuum=False, flushCache=False), - ExperimentConfig("test", "/u/drkp/sandbox/txcache/src/pgsql/obj", - reloadDB=False, vacuum=False, flushCache=False, - warmup=[100], makePropertiesArgs="short mediumsize errors", - useCache=True - ) +# ExperimentConfig("test", "/u/drkp/sandbox/txcache/src/pgsql/obj", +# reloadDB=False, vacuum=False, flushCache=False, +# warmup=[], makePropertiesArgs="medium mediumsize", +# useCache=True, microCache=True, freshnessReq=60) ] Index: /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/Makefile =================================================================== --- /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/Makefile (revision 3562) +++ /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/Makefile (working copy) @@ -31,7 +31,7 @@ ${JAVA} -classpath ./Client:./database edu.rice.rubis.client.InitDB ${PARAM} emulator: - ${JAVA} -classpath ./Client edu.rice.rubis.client.ClientEmulator + ${JAVA} -Xss64k -classpath ./Client edu.rice.rubis.client.ClientEmulator ############################ Index: /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/PHPprinter.php =================================================================== --- /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/PHPprinter.php (revision 3562) +++ /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/PHPprinter.php (working copy) @@ -6,6 +6,8 @@ if (isset($argv) && $argv) parse_str($argv[1], $HTTP_POST_VARS); +include("freshness.php"); + $postgres = true; // Whether or not to use TxCache. If false, just talks to Postgres // directly. @@ -199,7 +201,7 @@ if ($runningTransaction) die("ERROR: runningTransaction is non-null"); if (TXCACHE) - txcache_begin_ro($link[1], 30.0) or die("ERROR: Failed to beginRO"); + txcache_begin_ro($link[1], FRESHNESS) or die("ERROR: Failed to beginRO"); elseif ($postgres) sql_query("BEGIN READ ONLY", $link); else Index: /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/freshness.php =================================================================== --- /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/freshness.php (revision 0) +++ /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/freshness.php (revision 0) @@ -0,0 +1 @@ + \ No newline at end of file Index: /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/nodes.txt =================================================================== --- /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/nodes.txt (revision 3562) +++ /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/PHP/nodes.txt (working copy) @@ -1,3 +1,4 @@ -latest bounded pin with variety (5 to 20 secs) -localhost:16000 -localhost:16001 +latest bounded pin with variety (5 secs) +farm12.csail.mit.edu:16000 +farm12.csail.mit.edu:16001 +farm13.csail.mit.edu:16001 Index: /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/apache-rubis-austin =================================================================== --- /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/apache-rubis-austin (revision 3562) +++ /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/apache-rubis-austin (working copy) @@ -30,12 +30,12 @@ StartServers 5 MinSpareServers 5 MaxSpareServers 10 - MaxClients 150 + MaxClients 50 MaxRequestsPerChild 0 StartServers 2 - MaxClients 150 + MaxClients 50 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 Index: /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/make-properties =================================================================== --- /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/make-properties (revision 3562) +++ /u/drkp/sandbox/txcache/src/RUBiS-1.4.3/make-properties (working copy) @@ -114,7 +114,7 @@ # Workload: precise which transition table to use #workload_remote_client_nodes = farm1,farm3,farm4,farm6,farm7,farm8,farm9,farm10 workload_remote_client_nodes = ${REMOTE_CLIENTS} -workload_remote_client_command = $(which java) -classpath ${ROOT}/Client edu.rice.rubis.client.ClientEmulator +workload_remote_client_command = $(which java) -Xss64k -classpath ${ROOT}/Client edu.rice.rubis.client.ClientEmulator workload_number_of_clients_per_node = ${WORKLOAD_NUMBER_OF_CLIENTS_PER_NODE} workload_transition_table = ${WORKLOAD_TRANSITION_TABLE} Index: /u/drkp/sandbox/txcache/src/Makefile =================================================================== --- /u/drkp/sandbox/txcache/src/Makefile (revision 3562) +++ /u/drkp/sandbox/txcache/src/Makefile (working copy) @@ -6,7 +6,7 @@ LD = gcc EXPAND = lib/tmpl/expand -CFLAGS := -g -Wall +CFLAGS := -g -Wall -O2 override CFLAGS += -std=gnu99 LDFLAGS := # Debian package: check