From ea9291dd4547e4912e4e3fddde4cde5828ed4ba4 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 17 Sep 2009 00:38:10 +0000 Subject: [PATCH] code to do plots of transaction events.. --- Robust/TransSim/FlexScheduler.java | 49 +++++++++++++++++++++++++++--- Robust/TransSim/TransSim.java | 20 ++++++------ 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/Robust/TransSim/FlexScheduler.java b/Robust/TransSim/FlexScheduler.java index ccec667e..4cccba78 100644 --- a/Robust/TransSim/FlexScheduler.java +++ b/Robust/TransSim/FlexScheduler.java @@ -7,14 +7,14 @@ public class FlexScheduler { int deadlockcount; int checkdepth; - public FlexScheduler(Executor e, int policy, int abortThreshold, int abortRatio, int checkdepth) { - this(e, policy); + public FlexScheduler(Executor e, int policy, int abortThreshold, int abortRatio, int checkdepth, Plot p) { + this(e, policy, p); this.abortThreshold=abortThreshold; this.abortRatio=abortRatio; this.checkdepth=checkdepth; } - public FlexScheduler(Executor e, int policy) { + public FlexScheduler(Executor e, int policy, Plot p) { this.e=e; aborted=new boolean[e.numThreads()]; currentevents=new Event[e.numThreads()]; @@ -32,8 +32,25 @@ public class FlexScheduler { backoff[i]=BACKOFFSTART; threadinfo[i]=new ThreadInfo(this); } + this.p=p; + if (p!=null) { + serCommit=p.getSeries("COMMIT"); + serStart=p.getSeries("START"); + serAbort=p.getSeries("ABORT"); + serStall=p.getSeries("STALL"); + serWake=p.getSeries("WAKE"); + serAvoid=p.getSeries("AVOIDDEADLOCK"); + } } + Plot p; + Series serCommit; + Series serStart; + Series serAbort; + Series serStall; + Series serAvoid; + Series serWake; + public int getDeadLockCount() { return deadlockcount; } @@ -94,7 +111,9 @@ public class FlexScheduler { threadinfo[currthread].setStall(false); getmapping(threadinfo[currthread].getObject()).getWaiters().remove(currentevents[currthread]); } - + if (serAbort!=null) { + serAbort.addPoint(time, currthread); + } Transaction trans=currentevents[currthread].getTransaction(); releaseObjects(trans, currthread, time); @@ -127,6 +146,8 @@ public class FlexScheduler { waitit.remove(); waiter.setTime(time); threadinfo[waiter.getThread()].setStall(false); + if (serWake!=null) + serWake.addPoint(time,waiter.getThread()); oi.setOwner(waiter.getThread()); eq.add(waiter); break; @@ -169,6 +190,8 @@ public class FlexScheduler { } } shorttesttime=lasttime; + if (p!=null) + p.close(); } private ObjectInfo getmapping(int object) { @@ -190,6 +213,9 @@ public class FlexScheduler { //if it is a transaction, increment comit count if (trans.numEvents()>1||trans.getEvent(0)!=Transaction.DELAY) { commitcount++; + if (serCommit!=null) { + serCommit.addPoint(ev.getTime(),ev.getThread()); + } } //Reset our backoff counter backoff[ev.getThread()]=BACKOFFSTART; @@ -233,6 +259,8 @@ public class FlexScheduler { if (policy==LAZY||policy==LOCK) { //just flag to abort when it trie to commit aborted[threadid]=true; + if (serAbort!=null) + serAbort.addPoint(currtime, threadid); } else if (policy==COMMIT||policy==LOCKCOMMIT) { //abort it immediately reschedule(threadid, currtime); @@ -249,6 +277,12 @@ public class FlexScheduler { int nexttransnum=abort?ev.getTransNum():ev.getTransNum()+1; if (nexttransnum1||nexttrans.getEvent(0)!=Transaction.DELAY) { + serStart.addPoint(ev.getTime(),ev.getThread()); + } + } + Event nev=new Event(currtime+nexttrans.getTime(0), nexttrans, 0, ev.getThread(), nexttransnum); currentevents[ev.getThread()]=nev; eq.add(nev); @@ -378,10 +412,15 @@ public class FlexScheduler { //don't wait on stalled threads, we could deadlock threadinfo[ev.getThread()].setStall(true); threadinfo[ev.getThread()].setObject(object); + if (serStall!=null) + serStall.addPoint(ev.getTime(),ev.getThread()); oi.addWaiter(ev); return; - } else + } else { + if (serAvoid!=null) + serAvoid.addPoint(ev.getTime(),ev.getThread()); deadlockcount++; + } } else { //we have object oi.setOwner(ev.getThread()); diff --git a/Robust/TransSim/TransSim.java b/Robust/TransSim/TransSim.java index c0dacadb..f44c6acd 100644 --- a/Robust/TransSim/TransSim.java +++ b/Robust/TransSim/TransSim.java @@ -1,10 +1,10 @@ public class TransSim { public static void main(String[] args) { - int numThreads=64; + int numThreads=8; int numTrans=4; int deltaTrans=0; - int numObjects=4000; - int numAccesses=10; + int numObjects=200; + int numAccesses=20; int deltaAccesses=0; int readPercent=0; //time for operation @@ -27,7 +27,7 @@ public class TransSim { System.out.println("i="+i); Executor e=new Executor(numThreads, numTrans, deltaTrans, numObjects, i, deltaAccesses, readPercent, delay, deltaDelay, nonTrans, deltaNonTrans, splitobjects, splitaccesses, readPercentSecond); System.out.println(e.maxTime()); - FlexScheduler ls=new FlexScheduler(e, FlexScheduler.LAZY); + FlexScheduler ls=new FlexScheduler(e, FlexScheduler.LAZY, null); ls.dosim(); System.out.println("Lazy Time="+ls.getTime()); System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits()); @@ -35,7 +35,7 @@ public class TransSim { //Lock object accesses - ls=new FlexScheduler(e, FlexScheduler.LOCK, abortThreshold, abortRatio, deadlockdepth); + ls=new FlexScheduler(e, FlexScheduler.LOCK, abortThreshold, abortRatio, deadlockdepth, null); ls.dosim(); System.out.println("Deadlock count="+ls.getDeadLockCount()); System.out.println("Lock Abort="+ls.getTime()); @@ -43,7 +43,7 @@ public class TransSim { p.getSeries("LOCK").addPoint(i, ls.getTime()); //Lock Commit object accesses - ls=new FlexScheduler(e, FlexScheduler.LOCKCOMMIT, abortThreshold, abortRatio, deadlockdepth); + ls=new FlexScheduler(e, FlexScheduler.LOCKCOMMIT, abortThreshold, abortRatio, deadlockdepth, new Plot("FLEX"+i)); ls.dosim(); System.out.println("Deadlock count="+ls.getDeadLockCount()); System.out.println("LockCommit Abort="+ls.getTime()); @@ -51,28 +51,28 @@ public class TransSim { p.getSeries("LOCKCOMMIT").addPoint(i, ls.getTime()); //Kill others at commit - ls=new FlexScheduler(e, FlexScheduler.COMMIT); + ls=new FlexScheduler(e, FlexScheduler.COMMIT, null); ls.dosim(); System.out.println("Fast Abort="+ls.getTime()); System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits()); p.getSeries("COMMIT").addPoint(i, ls.getTime()); //Eager attack - ls=new FlexScheduler(e, FlexScheduler.ATTACK); + ls=new FlexScheduler(e, FlexScheduler.ATTACK, null); ls.dosim(); System.out.println("Attack Abort="+ls.getTime()); System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits()); p.getSeries("ATTACK").addPoint(i, ls.getTime()); //Eager polite - ls=new FlexScheduler(e, FlexScheduler.POLITE); + ls=new FlexScheduler(e, FlexScheduler.POLITE, null); ls.dosim(); System.out.println("Polite Abort="+ls.getTime()); System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits()); p.getSeries("POLITE").addPoint(i, ls.getTime()); //Karma - ls=new FlexScheduler(e, FlexScheduler.KARMA); + ls=new FlexScheduler(e, FlexScheduler.KARMA, null); ls.dosim(); System.out.println("Karma Abort="+ls.getTime()); System.out.println("Aborts="+ls.getAborts()+" Commit="+ls.getCommits()); -- 2.34.1