From 6f59839fb6f7910edd4e6fb68f47cdd3aa56c8be Mon Sep 17 00:00:00 2001 From: adash Date: Tue, 18 May 2010 22:47:04 +0000 Subject: [PATCH] commiting all latest changes to recovery folder --- .../Recovery/FileSystem/data/gen1.c | 4 +- .../Recovery/FileSystem/java/DFile.java | 30 ++ .../Recovery/FileSystem/java/Directory.java | 46 ++ .../FileSystem/java/DistributedHashMap.java | 136 ++++++ .../java/DistributedLinkedList.java | 226 +++++++++ .../Recovery/FileSystem/java/FileSystem.java | 326 +++---------- .../FileSystem/java/GlobalString.java | 173 +++++++ .../FileSystem/java/GlobalStringBuffer.java | 124 +++++ .../Recovery/FileSystem/java/makefile | 8 +- .../FileSystem/recovery/FileSystem.java | 456 ++++-------------- .../FileSystem/recovery/FileSystem2.java | 13 +- .../Recovery/FileSystem/recovery/dstm.conf | 8 - .../Recovery/FileSystem/recovery/makefile | 6 +- .../Recovery/Game/java/RainForest.java | 2 +- .../Recovery/MatrixMultiply/recovery/makefile | 4 +- .../Recovery/SpamFilter/recovery/dstm.conf | 7 + .../Recovery/SpamFilter/recovery/makefile | 4 +- Robust/src/Benchmarks/Recovery/bm_args.txt | 6 +- Robust/src/Benchmarks/Recovery/runjava.sh | 28 +- 19 files changed, 958 insertions(+), 649 deletions(-) create mode 100644 Robust/src/Benchmarks/Recovery/FileSystem/java/DFile.java create mode 100644 Robust/src/Benchmarks/Recovery/FileSystem/java/Directory.java create mode 100644 Robust/src/Benchmarks/Recovery/FileSystem/java/DistributedHashMap.java create mode 100644 Robust/src/Benchmarks/Recovery/FileSystem/java/DistributedLinkedList.java create mode 100644 Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalString.java create mode 100644 Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalStringBuffer.java delete mode 100644 Robust/src/Benchmarks/Recovery/FileSystem/recovery/dstm.conf diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/data/gen1.c b/Robust/src/Benchmarks/Recovery/FileSystem/data/gen1.c index 0a167d86..cdf9f1ab 100644 --- a/Robust/src/Benchmarks/Recovery/FileSystem/data/gen1.c +++ b/Robust/src/Benchmarks/Recovery/FileSystem/data/gen1.c @@ -16,7 +16,7 @@ #define HOME_DIR "home/adash" #define STR_SIZE 256 #define CREAT_FILE "creates.txt" -#define FACTOR (0.05) +#define FACTOR (0.10) unsigned int num_lines; @@ -102,7 +102,7 @@ void generateRdData(char *filename, int numRdCmd, int numCrCmd, int numCmd) for (i = 0; i < numCmd; i++) { int idx = rand() % numCrCmd; int test = rand() % 100; - if(test < 10 ) { + if(test < (FACTOR * 100)) { rd_data[idx][0] = 'c'; fprintf(fp, "%s", rd_data[idx]); } else { diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/java/DFile.java b/Robust/src/Benchmarks/Recovery/FileSystem/java/DFile.java new file mode 100644 index 00000000..618884f8 --- /dev/null +++ b/Robust/src/Benchmarks/Recovery/FileSystem/java/DFile.java @@ -0,0 +1,30 @@ +public class DFile { + char [] data; + int size; + public DFile() { + data= new char[4096]; + size=data.length; + } + public void write(int offset, char[] towrite) { + int length=offset+towrite.length; + if (length>size) { + if (length>data.length) { + char [] ptr= new char[length]; + for(int i=0;i */ - - -public class FileSystem { - HashMap dir; // Directory - HashMap fs; // File system - LinkedList dir_list; - String inputfile; - int mid; - - public FileSystem(HashMap dir, HashMap fs, LinkedList dir_list, String filename) { - this.dir = dir; - this.fs = fs; - this.dir_list = dir_list; - this.inputfile = new String("../data/"+filename + "0"); - } - - public void init() { - fillHashTable(); - } - - public void fillHashTable() { - String path; - LinkedList list; - - path = new String("/home/"); // root is 'home' - list = new LinkedList(); - - dir.put(path, list); - dir_list.add(path); - } - - public static void fillTodoList(String file, LinkedList todoList) { - FileInputStream fis; - String comm; - char c; - String key; - String val; - Transaction t; - - fis = new FileInputStream(file); - - while ((comm = fis.readLine()) != null) { // 'command' 'path' - c = comm.charAt(0); // ex) w /home/abc.c - key = comm.subString(2); - t = new Transaction(c, key); - todoList.add(t); - } - } - - public void execute() { - Transaction t; - - char command; - String key; - String val; - boolean isDir; - - int index; - - LinkedList todoList = new LinkedList(); - fillTodoList(inputfile, todoList); - - long st = System.currentTimeMillis(); - long fi; - while (!todoList.isEmpty()) { - t = (Transaction)(todoList.removeFirst()); - - command = t.getCommand(); - key = t.getKey(); - - index = key.lastindexOf('/'); - if (index+1 == key.length()) - isDir = true; - else - isDir = false; - - if (command == 'r') { - //System.out.println("["+command+"] ["+key+"]"); - if (isDir == true) { - readDirectory(key); - } - else { - readFile(key); - } +public class FileSystem extends Thread { + Directory root; + Directory current; + int mid; + + public FileSystem(Directory root, int mid) { + this.root=root; + this.mid = mid; + } + + public void getRoot() { + current=root; + } + + public DFile getFile(GlobalString name) { + return current.getFile(name); + } + + public DFile createFile(GlobalString name) { + return current.createFile(name); + } + + public void run() { + long st = System.currentTimeMillis(); + long fi; + { + current=root.makeDirectory( new GlobalString(String.valueOf(mid))); + } + Random r=new Random(); + char ptr[]=new char[1024]; + for(int i=0;i<40000;i++) { + { + for(int count=0;count<10;count++) { + int value=r.nextInt(100); + GlobalString filename= new GlobalString(String.valueOf(r.nextInt(200))); + if (value<10) {//10% writes + //System.out.println("Write: "); + //Do write + DFile f=getFile(filename); + if (f==null) { + f=createFile(filename); + } + f.write(10,ptr); + } else { + //System.out.println("Read: "); + //Do read + DFile f=getFile(filename); + if(f!=null) + f.read(); + } + } } - else if (command == 'c') { - //System.out.println("["+command+"] ["+key+"]"); - if (isDir == true) { - createDirectory(key); - } - else { - val = t.getValue(); - val = new String(val); - createFile(key, val); - } - } } fi = System.currentTimeMillis(); System.out.println("\n\n\n I'm done - Time Elapse : "+ ((double)(fi-st)/1000) + "\n\n\n"); + } - //output(); - -// RecoveryStat.printRecoveryStat(); - } - - public void output() { - Iterator iter; - String str; - - iter = dir_list.iterator(); - - while (iter.hasNext()) { - str = (String)(iter.next()); - //System.printString(str + "\n"); - } - } - - public void readFile(String key) { - String val; + public static void main(String[] args) { + int NUM_THREADS = 3; - val = (String)(fs.get(key)); - if (val != null) { -// System.out.println("<"+val+">"); - } - else { - System.out.println("No such file or directory"); - } - } - - public void readDirectory(String key) { - LinkedList list; - Iterator iter; - String val; - - list = (LinkedList)(dir.get(key)); - - if (list != null) { - iter = list.iterator(); - while (iter.hasNext() == true) { - val = (String)(iter.next()); -// System.out.print("["+val+"] "); - } -// System.out.println(""); - } - else { - System.out.println("No such file or directory"); - } - } - - public void createFile(String key, String val) { - String path; - String target; - int index; - LinkedList list; - - index = key.lastindexOf('/'); - path = key.subString(0, index+1); - target = key.subString(index+1); - - if (dir.containsKey(path)) { - list = (LinkedList)(dir.get(path)); - list.push(target); - dir.put(path, list); - fs.put(key, val); - } - else { - System.out.println("Cannot create file"); - } - } - - public void createDirectory(String key) { - int index; - String path; - String target; - LinkedList list; - - index = key.lastindexOf('/', key.length()-2); - - if (index != -1) { - path = key.subString(0, index+1); - target = key.subString(index+1); - - if (dir.containsKey(path)) { - list = (LinkedList)(dir.get(path)); - list.push(target); - dir.put(path, list); - - list = new LinkedList(); - dir.put(key, list); - dir_list.add(key); - } - else { - System.out.println("Cannot create directory"); - } - } - } - - public static void main(String[] args) { - String filename; - int NUM_THREADS = 1; - - if (args.length == 2) { - NUM_THREADS = Integer.parseInt(args[0]); - filename = args[1]; - } - else { - System.out.println("usage: ./FileSystem.bin "); - System.exit(0); - } - - FileSystem file; + if (args.length == 1) { + NUM_THREADS = Integer.parseInt(args[0]); + } + else { + System.out.println("./FileSystem.bin master "); + System.exit(0); + } - HashMap fs = new HashMap(500, 0.75f); // file system - HashMap dir = new HashMap(500, 0.75f); // directory - LinkedList dir_list = new LinkedList(); - - file = new FileSystem(dir, fs, dir_list, filename); - file.init(); + FileSystem[] lus; + { + Directory root= new Directory(null); + lus = new FileSystem[NUM_THREADS]; + for(int i = 0; i < NUM_THREADS; i++) { + lus[i] = new FileSystem(root, i); + } + } - file.execute(); - - System.printString("Finished\n"); - } -} + FileSystem tmp; + /* Start threads */ + for(int i = 0; i < NUM_THREADS; i++) { + { + tmp = lus[i]; + } + tmp.run(); + } -public class Transaction { // object for todoList - char command; // r: read, w: write - String key; - String val; - - Transaction (char c, String key) { - command = c; - - this.key = new String(key); - this.val = new String(); - } - - Transaction (char c, String key, String val) { - command = c; - - this.key = new String(key); - this.val = new String(val); - } - - public char getCommand() { - return command; - } - - public String getKey() { - return key; - } - - public String getValue() { - return val; - } + System.printString("Finished\n"); + } } diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalString.java b/Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalString.java new file mode 100644 index 00000000..a488c66f --- /dev/null +++ b/Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalString.java @@ -0,0 +1,173 @@ +public class GlobalString { + char value[]; + int count; + int offset; + private int cachedHashcode; + + public GlobalString() { + } + + public GlobalString(String str) { + { + value = new char[str.count]; + for(int i =0; i< str.count;i++) { + value[i] = str.value[i+str.offset]; + } + count = str.count; + offset = 0; + } + } + + public GlobalString(GlobalString gstr) { + { + this.value = gstr.value; + this.count = gstr.count; + this.offset = gstr.offset; + } + } + + public GlobalString(GlobalStringBuffer gsb) { + { + value = new char[gsb.length()]; + count = gsb.length(); + offset = 0; + for (int i = 0; i < count; i++) + value[i] = gsb.value[i]; + } + } + + public int hashCode() { + if (cachedHashcode!=0) + return cachedHashcode; + int hashcode=0; + for(int i=0; i 0; i--) + if (this.charAt(i) == ch) + return i; + return -1; + } + + public char charAt(int i) { + return value[i+offset]; + } + + public int indexOf(GlobalString str) { + return this.indexOf(str, 0); + } + + public int indexOf(GlobalString str, int fromIndex) { + if (fromIndex < 0) + fromIndex = 0; + for (int i = fromIndex; i <= (count-str.count); i++) + if (regionMatches(i, str, 0, str.count)) + return i; + return -1; + } + + public boolean regionMatches(int toffset, GlobalString other, int ooffset, int len) { + if (toffset < 0 || ooffset < 0 || (toffset+len) > count || (ooffset+len) > other.count) + return false; + + for (int i = 0; i < len; i++) { + if (other.value[i+other.offset+ooffset] != this.value[i+this.offset+toffset]) + return false; + } + return true; + } + + public GlobalString substring(int beginIndex) { + return substring(beginIndex, this.count); + } + + public GlobalString subString(int beginIndex) { + return subString(beginIndex, this.count); + } + + public GlobalString subString(int beginIndex, int endIndex) { + return substring(beginIndex, endIndex); + } + + public GlobalString substring(int beginIndex, int endIndex) { + GlobalString str; + { + str = new GlobalString(); + } + if (beginIndex > this.count || endIndex > this.count || beginIndex > endIndex) { + System.printString("Index error\n"); + } + { + str.value = this.value; + str.count = endIndex-beginIndex; + str.offset = this.offset + beginIndex; + } + return str; + } + + public boolean equals(String str) { + GlobalString gstr; + + { + gstr = new GlobalString(str); + } + return equals(gstr); + } + + public boolean equals(Object o) { + if (o.getType()!= getType()) + return false; + + GlobalString gs = (GlobalString)o; + if (gs.count!= count) + return false; + + for(int i = 0; i < count; i++) { + if (gs.value[i+gs.offset] != value[i+offset]) + return false; + } + return true; + } +} diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalStringBuffer.java b/Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalStringBuffer.java new file mode 100644 index 00000000..854cf921 --- /dev/null +++ b/Robust/src/Benchmarks/Recovery/FileSystem/java/GlobalStringBuffer.java @@ -0,0 +1,124 @@ +public class GlobalStringBuffer { + char value[]; + int count; + // private static final int DEFAULTSIZE=16; + + public GlobalStringBuffer(String str) { + GlobalString gstr; + + { + gstr = new GlobalString(str); + } + GlobalStringBuffer(gstr); + } + + public GlobalStringBuffer(GlobalString str) { + { + value = new char[str.count+16]; + count = str.count; + for (int i = 0; i < count; i++) + value[i] = str.value[i+str.offset]; + } + } + + public GlobalStringBuffer(StringBuffer sb) { + { + value = new char[sb.count]; + for (int i = 0; i < sb.count; i++) + value[i] = sb.value[i]; + count = sb.count; + } + } + + public GlobalStringBuffer() { + { + value = new char[16]; //16 is DEFAULTSIZE + count = 0; + } + } + + public int length() { + return count; + } + + public int capacity() { + return value.length; + } + + public char charAt(int x) { + return value[x]; + } + + public GlobalStringBuffer append(char c) { + return append(String.valueOf(c)); + } + + public GlobalStringBuffer append(String s) { + GlobalString str; + { + str = new GlobalString(s); + } + return append(str); + } + + public GlobalStringBuffer append(GlobalString s) { + { + if ((s.count+count) > value.length) { + // Need to allocate + char newvalue[] = new char[s.count+count+16]; //16 is DEFAULTSIZE + for(int i = 0; i < count; i++) + newvalue[i] = value[i]; + for(int i = 0; i < s.count; i++) + newvalue[i+count] = s.value[i+s.offset]; + value = newvalue; + count += s.count; + } else { + for(int i = 0; i < s.count; i++) { + value[i+count] = s.value[i+s.offset]; + } + count += s.count; + } + } + return this; + } + + public GlobalStringBuffer append(StringBuffer s) { + GlobalStringBuffer gsb; + { + gsb = new GlobalStringBuffer(s); + } + return append(gsb); + } + + + public GlobalStringBuffer append(GlobalStringBuffer s) { + { + if ((s.count+count) > value.length) { + // Need to allocate + char newvalue[] = new char[s.count+count+16]; //16 is DEFAULTSIZE + for(int i = 0; i < count; i++) + newvalue[i] = value[i]; + for(int i = 0; i < s.count; i++) + newvalue[i+count] = s.value[i]; + value = newvalue; + count += s.count; + } else { + for(int i = 0; i < s.count; i++) { + value[i+count] = s.value[i]; + } + count += s.count; + } + } + return this; + } + + public GlobalString toGlobalString() { + return new GlobalString(this); + } + + public String toLocalString() { + GlobalString gstr = this.toGlobalString(); + return gstr.toLocalString(); + } + +} diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/java/makefile b/Robust/src/Benchmarks/Recovery/FileSystem/java/makefile index ab7f23e7..852a27f0 100644 --- a/Robust/src/Benchmarks/Recovery/FileSystem/java/makefile +++ b/Robust/src/Benchmarks/Recovery/FileSystem/java/makefile @@ -1,5 +1,11 @@ MAINCLASS=FileSystem -SRC1=${MAINCLASS}.java +SRC1=${MAINCLASS}.java \ + Directory.java \ + DFile.java \ + DistributedHashMap.java \ + GlobalString.java \ + GlobalStringBuffer.java \ + DistributedLinkedList.java FLAGS= -optimize -thread -mainclass ${MAINCLASS} default: ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC1} diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem.java b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem.java index 9e5508b9..c66c30ab 100644 --- a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem.java +++ b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem.java @@ -5,391 +5,113 @@ Usage : */ public class FileSystem extends Thread { - DistributedHashMap dir; // Directory - DistributedHashMap fs; // File - DistributedLinkedList dir_list; - GlobalString inputfile; - int mid; - int threadid; - - public FileSystem(DistributedHashMap dir, DistributedHashMap fs, DistributedLinkedList dir_list) { - this.dir = dir; - this.fs = fs; - this.dir_list = dir_list; - } - - public FileSystem(DistributedHashMap dir, DistributedHashMap fs, DistributedLinkedList dir_list, String filename, int mid,int threadid) { - this.dir = dir; - this.fs = fs; - this.dir_list = dir_list; - this.mid = mid; - this.threadid = threadid; - this.inputfile = global new GlobalString("../data/"+filename + mid); - } + Directory root; + Directory current; + int mid; + public FileSystem(Directory root, int mid) { + this.root=root; + this.mid = mid; + } - public void setInputFileName(String filename, int mid) { - this.mid = mid; - this.inputfile = global new GlobalString("../data/"+filename + mid); - } - - public void init() { - fillHashTable(); - } - - public void fillHashTable() { - GlobalString path; - DistributedLinkedList list; - - atomic { - path = global new GlobalString("/tmp/"); // root is 'tmp' - list = global new DistributedLinkedList(); - - dir.put(path, list); - dir_list.add(path); - } - } - - public static void fillTodoList(String file, LinkedList todoList) { - FileInputStream fis; - String comm; - char c; - String key; - String val; - Transaction t; - - fis = new FileInputStream(file); + public void getRoot() { + current=root; + } - while ((comm = fis.readLine()) != null) { // 'command' 'path' - c = comm.charAt(0); // ex) w /home/abc.c - key = comm.subString(2); - t = new Transaction(c, key); - todoList.add(t); - } - } + public DFile getFile(GlobalString name) { + return current.getFile(name); + } - public void run() { - System.out.println("Inside run method\n"); - Transaction t; - char command; - String key; - String val; - GlobalString gkey; - GlobalString gval; - boolean isDir; + public DFile createFile(GlobalString name) { + return current.createFile(name); + } - int index; - String file; + public void run() { + long st = System.currentTimeMillis(); + long fi; + atomic { + current=root.makeDirectory(global new GlobalString(String.valueOf(mid))); + } + Random r=new Random(); + char ptr[]=new char[1024]; + for(int i=0;i<40000;i++) { atomic { - System.out.println("trans1"); - file = inputfile.toLocalString(); - } - - System.out.println("file= " + file); - - LinkedList todoList = new LinkedList(); - fillTodoList(file, todoList); - - long st = System.currentTimeMillis(); - long fi; - long tot1; - - if(todoList.isEmpty()) - System.out.println("todoList is Empty\n"); - - int iter = 0; - while (!todoList.isEmpty()) { - //System.out.println("iter= " + iter + "\n"); - int count = 5; - atomic { - //System.out.println("trans2"); - while(count>0 && !todoList.isEmpty()) { //commit 5 transactions - t = (Transaction)(todoList.removeFirst()); - if(t==null) { - count--; - continue; - } - command = t.getCommand(); - key = t.getKey(); - //System.out.println(key + "\n"); - gkey = global new GlobalString(key); - - index = key.lastindexOf('/'); - if (index+1 == key.length()) - isDir = true; - else - isDir = false; - - long st1 = 0L; - long fi1 = 0L; - if (command == 'r') { - st1 = System.currentTimeMillis(); - //System.out.println("["+command+"] ["+key+"]"); - if (isDir == true) { - readDirectory(gkey); - } - else { - readFile(gkey); - } - fi1 = System.currentTimeMillis(); - } - tot1 += fi1 - st1; - if (command == 'c') { - //System.out.println("["+command+"] ["+key+"]"); - if (isDir == true) { - createDirectory(gkey); - } - else { - val = t.getValue(); - gval = global new GlobalString(val); - createFile(gkey, gval); - } - } - count--; - }//end of inside loop - }//end of atomic - iter++; - } - fi = System.currentTimeMillis(); - - // sleep(3000000); - // atomic { - // output(); - // } - - RecoveryStat.printRecoveryStat(); - - System.out.println("\n\n\n I'm done - Time Elapse : "+ ((double)(fi-st)/1000) + "\n\n\n"); - System.out.println("\n Reading - Time Elapse : "+ ((double)tot1/1000) + "\n"); - while(true) { - sleep(100000); + for(int count=0;count<10;count++) { + int value=r.nextInt(100); + GlobalString filename=global new GlobalString(String.valueOf(r.nextInt(200))); + if (value<10) {//10% writes + //System.out.println("Write: "); + //Do write + DFile f=getFile(filename); + if (f==null) { + f=createFile(filename); + } + f.write(10,ptr); + } else { + //System.out.println("Read: "); + //Do read + DFile f=getFile(filename); + if(f!=null) + f.read(); + } + } } } + fi = System.currentTimeMillis(); + RecoveryStat.printRecoveryStat(); + System.out.println("\n\n\n I'm done - Time Elapse : "+ ((double)(fi-st)/1000) + "\n\n\n"); + while(true) { + sleep(100000); + } + } - /* - public void output() { - Iterator iter; - GlobalString gstr; - iter = dir_list.iterator(); - - while (iter.hasNext()) { - gstr = (GlobalString)(iter.next()); - System.printString(gstr.toLocalString() + "\n"); - } - } - */ - - public void readFile(GlobalString gkey) { - GlobalString gval=null; - String val=null; - - //atomic { - gval = (GlobalString)(fs.get(gkey)); - if(gval!=null) { - val = gval.toLocalString(); - //Add some useless extra work for now - //to increase read time - int hashVal = gval.hashCode(); - int a=0; - for(int t=0; t"); - } - else { - //System.out.println("No such file or directory"); - } - } - - public void readDirectory(GlobalString gkey) { - DistributedLinkedList list; - Iterator iter; - GlobalString gval; - - list = (DistributedLinkedList)(dir.get(gkey)); - - if (list != null) { - iter = list.iterator(); - while (iter.hasNext() == true) { - gval = (GlobalString)(iter.next()); - //System.out.print("["+gval.toLocalString()+"] "); - //Add some useless extra work for now - int hashVal = gval.hashCode(); - int a=0; - for(int t=0; t"); + System.exit(0); + } - if (args.length == 2) { - NUM_THREADS = Integer.parseInt(args[0]); - filename = args[1]; - System.out.println("filename= " + filename); - } - else { - System.out.println("./FileSystem.bin master "); - System.exit(0); + int[] mid = new int[8]; + mid[0] = (128<<24)|(195<<16)|(136<<8)|162;//dc-1 + mid[1] = (128<<24)|(195<<16)|(136<<8)|163;//dc-2 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164;//dc-3 + mid[3] = (128<<24)|(195<<16)|(136<<8)|165;//dc-4 + mid[4] = (128<<24)|(195<<16)|(136<<8)|166;//dc-5 + mid[5] = (128<<24)|(195<<16)|(136<<8)|167;//dc-6 + mid[6] = (128<<24)|(195<<16)|(136<<8)|168;//dc-7 + mid[7] = (128<<24)|(195<<16)|(136<<8)|169;//dc-8 + + FileSystem[] lus; + atomic { + Directory root=global new Directory(null); + lus = global new FileSystem[NUM_THREADS]; + for(int i = 0; i < NUM_THREADS; i++) { + lus[i] = global new FileSystem(root, i); } + } - int[] mid = new int[8]; - /* - mid[0] = (128<<24)|(195<<16)|(180<<8)|21;//dw-2 - mid[1] = (128<<24)|(195<<16)|(180<<8)|26;//dw-7 - */ - mid[0] = (128<<24)|(195<<16)|(136<<8)|162;//dc-1 - mid[1] = (128<<24)|(195<<16)|(136<<8)|163;//dc-2 - mid[2] = (128<<24)|(195<<16)|(136<<8)|164;//dc-3 - mid[3] = (128<<24)|(195<<16)|(136<<8)|165;//dc-4 - mid[4] = (128<<24)|(195<<16)|(136<<8)|166;//dc-5 - mid[5] = (128<<24)|(195<<16)|(136<<8)|167;//dc-6 - mid[6] = (128<<24)|(195<<16)|(136<<8)|168;//dc-7 - mid[7] = (128<<24)|(195<<16)|(136<<8)|169;//dc-8 - - FileSystem[] lus; - FileSystem initLus; - + FileSystem tmp; + /* Start threads */ + for(int i = 0; i < NUM_THREADS; i++) { atomic { - DistributedHashMap fs = global new DistributedHashMap(500, 100, 0.75f); - DistributedHashMap dir = global new DistributedHashMap(500, 100, 0.75f); - DistributedLinkedList dir_list = global new DistributedLinkedList(); - - initLus = global new FileSystem(dir, fs, dir_list); - initLus.init(); - - lus = global new FileSystem[NUM_THREADS]; - for(int i = 0; i < NUM_THREADS; i++) { - lus[i] = global new FileSystem(initLus.dir, initLus.fs, initLus.dir_list, filename, i,mid[i]); - } - } - - FileSystem tmp; - /* Start threads */ - for(int i = 0; i < NUM_THREADS; i++) { - atomic { - tmp = lus[i]; - } - Thread.myStart(tmp, mid[i]); + tmp = lus[i]; } + Thread.myStart(tmp, mid[i]); + } - /* Join threads */ - for(int i = 0; i < NUM_THREADS; i++) { - atomic { - tmp = lus[i]; - } - tmp.join(); + /* Join threads */ + for(int i = 0; i < NUM_THREADS; i++) { + atomic { + tmp = lus[i]; } - - System.printString("Finished\n"); + tmp.join(); } -} - -public class Transaction { // object for todoList - char command; // r: read, w: write - String key; - String val; - - Transaction (char c, String key) { - command = c; - - this.key = new String(key); - this.val = new String(); - } - - Transaction (char c, String key, String val) { - command = c; - - this.key = new String(key); - this.val = new String(val); - } - - public char getCommand() { - return command; - } - - public String getKey() { - return key; - } - public String getValue() { - return val; + System.printString("Finished\n"); } } diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem2.java b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem2.java index d2bdd94c..d30bb5c2 100644 --- a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem2.java +++ b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/FileSystem2.java @@ -76,7 +76,7 @@ public class FileSystem extends Thread { fillTodoList(file, todoList); long st = System.currentTimeMillis(); long fi; - long tot1, tot2; + long tot1=0, tot2=0; if(todoList.isEmpty()) System.out.println("todoList is Empty\n"); @@ -84,6 +84,7 @@ public class FileSystem extends Thread { while (!todoList.isEmpty()) { int count = 10; atomic { + System.out.println("trans1, count= "+ count); while(count>0 && !todoList.isEmpty()) { //commit 10 transactions t = (Transaction)(todoList.removeFirst()); if(t==null) { @@ -103,7 +104,7 @@ public class FileSystem extends Thread { if (command == 'r') { long st1 = System.currentTimeMillis(); - //System.out.println("["+command+"] ["+key+"]"); + System.out.println("["+command+"] ["+key+"]"); if (isDir != true) { readFile(gkey); } @@ -113,7 +114,7 @@ public class FileSystem extends Thread { if (command == 'c') { long st2 = System.currentTimeMillis(); - //System.out.println("["+command+"] ["+key+"]"); + System.out.println("["+command+"] ["+key+"]"); if (isDir != true) { String val = "Testrun"; GlobalString gval = global new GlobalString(val); @@ -148,6 +149,11 @@ public class FileSystem extends Thread { //System.out.println("readFile(): ["+gkey.toLocalString()+"] "); //Add some useless extra work for now //to increase read time + int[] b = new int[4096]; + for(int i = 0; i< 4096; i++) { + b[i] = 0; + } + /* String filename = gkey.toLocalString(); FileInputStream inputFile = new FileInputStream(filename); int n; @@ -158,6 +164,7 @@ public class FileSystem extends Thread { } } inputFile.close(); + */ /* int hashVal = val.hashCode(); int a=0; diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/dstm.conf b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/dstm.conf deleted file mode 100644 index b958650b..00000000 --- a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/dstm.conf +++ /dev/null @@ -1,8 +0,0 @@ -128.195.136.162 -128.195.136.163 -#128.195.136.164 -#128.195.136.165 -#128.195.136.166 -#128.195.136.167 -#128.195.136.168 -#128.195.136.169 diff --git a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/makefile b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/makefile index 28a64ed3..4d744bd5 100644 --- a/Robust/src/Benchmarks/Recovery/FileSystem/recovery/makefile +++ b/Robust/src/Benchmarks/Recovery/FileSystem/recovery/makefile @@ -1,6 +1,8 @@ MAINCLASS=FileSystem -SRC1=${MAINCLASS}2.java \ - DistributedHashMap.java +SRC1=${MAINCLASS}.java \ + DistributedHashMap.java \ + Directory.java \ + DFile.java FLAGS= -recovery -recoverystats -transstats -dsm -dsmcaching -debug -optimize -mainclass ${MAINCLASS} DSMFLAGS=-transstats -dsm -dsmcaching -optimize -mainclass ${MAINCLASS} default: diff --git a/Robust/src/Benchmarks/Recovery/Game/java/RainForest.java b/Robust/src/Benchmarks/Recovery/Game/java/RainForest.java index a818bb7b..c5b1b6d3 100644 --- a/Robust/src/Benchmarks/Recovery/Game/java/RainForest.java +++ b/Robust/src/Benchmarks/Recovery/Game/java/RainForest.java @@ -1,6 +1,6 @@ #define ROW 400 /* columns in the map */ #define COLUMN 100 /* rows of in the map */ -#define ROUNDS 2000 /* Number of moves by each player */ +#define ROUNDS 200 /* Number of moves by each player */ #define PLAYERS 20 /* Number of Players when num Players != num of client machines */ #define RATI0 0.5 /* Number of lumberjacks to number of planters */ #define BLOCK 3 /* Area around the gamer to consider */ diff --git a/Robust/src/Benchmarks/Recovery/MatrixMultiply/recovery/makefile b/Robust/src/Benchmarks/Recovery/MatrixMultiply/recovery/makefile index 18b2a1b5..e06976d7 100644 --- a/Robust/src/Benchmarks/Recovery/MatrixMultiply/recovery/makefile +++ b/Robust/src/Benchmarks/Recovery/MatrixMultiply/recovery/makefile @@ -6,9 +6,9 @@ SRC1=${MAINCLASS}.java \ Worker.java \ ../../../../ClassLibrary/JavaDSM/RecoveryStat.java -FLAGS=-recovery -recoverystats -transstats -dsm -dsmtask -prefetch -dsmcaching -32bit -debug -optimize -mainclass ${MAINCLASS} -excprefetch Task.isTodoListEmpty -excprefetch MatrixMultiply.output -excprefetch GlobalQueue.push -excprefetch MatrixMultiply.fillTodoList -excprefetch GlobalQueue.pop -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -excprefetch Work.checkCurrentWorkList -excprefetch MMul.getSum -excprefetch Task.grabTask -excprefetch Worker.Worker -excprefetch Task.dequeueTask -trueprob 0.96 +FLAGS=-recovery -recoverystats -dsm -dsmtask -prefetch -dsmcaching -32bit -optimize -mainclass ${MAINCLASS} -excprefetch Task.isTodoListEmpty -excprefetch MatrixMultiply.output -excprefetch GlobalQueue.push -excprefetch MatrixMultiply.fillTodoList -excprefetch GlobalQueue.pop -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -excprefetch Work.checkCurrentWorkList -excprefetch MMul.getSum -excprefetch Task.grabTask -excprefetch Worker.Worker -excprefetch Task.dequeueTask -excprefetch Worker.run -trueprob 0.96 DSMFLAGS= -dsm -dsmtask -transstats -dsmcaching -32bit -optimize -mainclass ${MAINCLASS} -excprefetch Task.isTodoListEmpty -excprefetch MatrixMultiply.output -excprefetch GlobalQueue.push -excprefetch MatrixMultiply.fillTodoList -excprefetch GlobalQueue.pop -excprefetch MatrixMultiply.main -excprefetch MMul.setValues -excprefetch MMul.transpose -excprefetch Work.checkCurrentWorkList -excprefetch MMul.getSum -excprefetch Task.grabTask -RECOVERYFLAGS=-recovery -dsm -dsmtask -nooptimize -debug -mainclass ${MAINCLASS} +RECOVERYFLAGS=-recovery -dsm -dsmtask -optimize -debug -mainclass ${MAINCLASS} default: ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC1} diff --git a/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/dstm.conf b/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/dstm.conf index b56fa580..cbce2d59 100644 --- a/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/dstm.conf +++ b/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/dstm.conf @@ -1 +1,8 @@ 128.195.136.162 +128.195.136.163 +128.195.136.164 +128.195.136.165 +128.195.136.166 +128.195.136.167 +128.195.136.168 +128.195.136.169 diff --git a/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/makefile b/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/makefile index ecd358ee..b1d6f184 100644 --- a/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/makefile +++ b/Robust/src/Benchmarks/Recovery/SpamFilter/recovery/makefile @@ -11,10 +11,12 @@ SRC=${MAINCLASS}.java \ GString.java \ WhiplashSignature.java -FLAGS= -prefetch -dsmcaching -dsm -recoverystats -recovery -optimize -mainclass ${MAINCLASS} +FLAGS=-recovery -recoverystats -dsm -dsmcaching -prefetch -transstats -32bit -debug -optimize -mainclass ${MAINCLASS} -excprefetch HashStat.setuser -excprefetch String.hashCode -excprefetch String.equals -excprefetch HashStat.HashStat -excprefetch GString.toLocalCharArray -excprefetch SpamFilter.main -excprefetch HashEntry.getEngine -excprefetch HashEntry.getSignature -excprefetch HashStat.setuserid -excprefetch HashEntry.hashCode -excprefetch HashEntry.equals -excprefetch GString.GString -excprefetch SpamFilter.sendFeedBack -excprefetch HashStat.incSpamCount -excprefetch HashStat.incHamCount -trueprob 0.98 +DSMFLAGS=-dsm -dsmcaching -prefetch -transstats -32bit -optimize -mainclass ${MAINCLASS} -excprefetch HashStat.setuser -excprefetch String.hashCode -excprefetch String.equals -excprefetch HashStat.HashStat -excprefetch GString.toLocalCharArray -excprefetch SpamFilter.main -excprefetch HashEntry.getEngine -excprefetch HashEntry.getSignature -excprefetch HashStat.setuserid -excprefetch HashEntry.hashCode -excprefetch HashEntry.equals -excprefetch GString.GString -excprefetch SpamFilter.sendFeedBack -excprefetch HashStat.incSpamCount -excprefetch HashStat.incHamCount -trueprob 0.98 default: ../../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC} +# ../../../../buildscript ${DSMFLAGS} -o ${MAINCLASS}DSM ${SRC} clean: rm -rf tmpbuilddirectory* diff --git a/Robust/src/Benchmarks/Recovery/bm_args.txt b/Robust/src/Benchmarks/Recovery/bm_args.txt index cba85cbf..7d64dfe7 100644 --- a/Robust/src/Benchmarks/Recovery/bm_args.txt +++ b/Robust/src/Benchmarks/Recovery/bm_args.txt @@ -1,5 +1,5 @@ -testcase 8 MatrixMultiply:1600 80 -testcase 8 Spider:"www.uci.edu" 4 -testcase 8 FileSystem:newdata +testcase 8 MatrixMultiply:2048 80 +testcase 8 Spider:"dc-11.calit2.uci.edu" 10 +testcase 8 FileSystem: testcase 8 SpamFilter:-e 500 -n 10 testcase 8 Game: diff --git a/Robust/src/Benchmarks/Recovery/runjava.sh b/Robust/src/Benchmarks/Recovery/runjava.sh index c740a9d4..85e45fee 100755 --- a/Robust/src/Benchmarks/Recovery/runjava.sh +++ b/Robust/src/Benchmarks/Recovery/runjava.sh @@ -10,8 +10,8 @@ BASEDIR=`pwd` RECOVERYDIR='recovery' JAVASINGLEDIR='java' -WAITTIME=75 -KILLDELAY=2 +WAITTIME=120 +KILLDELAY=10 LOGDIR=~/research/Robust/src/Benchmarks/Recovery/runlog DSTMDIR=${HOME}/research/Robust/src/Benchmarks/Prefetch/config MACHINELIST='dc-1.calit2.uci.edu dc-2.calit2.uci.edu dc-3.calit2.uci.edu dc-4.calit2.uci.edu dc-5.calit2.uci.edu dc-6.calit2.uci.edu dc-7.calit2.uci.edu dc-8.calit2.uci.edu' @@ -26,7 +26,7 @@ ORDER=( 0 1 3 5 7 8 2 0 8 7 3 6 5 4 0 7 4 6 8 1 2 ); -#ORDER=( 0 1 3 5 7 8 2 ); +#ORDER=( 0 1 8 4 6 3 7 ); # # killClients <# of machines> @@ -104,7 +104,7 @@ function runNormalTest { runMachines log sleep $WAITTIME - killclientswithSignal $fName $2 + killclientswithSignal $fName 8 #killclients $fName 8 sleep 10 cd - @@ -125,7 +125,8 @@ function runFailureTest { if [ $k -eq 0 ]; then # if k = 0, it is a new test if [ $test_iter -ne 1 ]; then sleep $WAITTIME # wait the end of execution - killclients $fName 8 # kill alive machines +#killclients $fName 8 # kill alive machines + killclientswithSignal $fName 8 #kill machines when there is more than 1 order outputIter=0; for outputIter in 1 2 3 4 5 6 7 8 do @@ -152,8 +153,9 @@ function runFailureTest { fi done + sleep $WAITTIME # wait the end of execution # killclients $fName 8 # kill alive machines - killclientswithSignal $fName 8 + killclientswithSignal $fName 8 #kill machines when finished processing everything in ORDER{ } sleep 10 cd - } @@ -310,19 +312,19 @@ function testcase { # javasingle 1 ${BM_NAME} # cd $TOPDIR # echo "=================================================================================" -# -# echo "=============== Running recoverysingle for ${BM_NAME} on 1 machines =================" -# recoverysingle 2 ${BM_NAME} + +# echo "=============== Running recoverysingle for ${BM_NAME} on 1 machines =================" +# recoverysingle 1 ${BM_NAME} # cd $TOPDIR # echo "=================================================================================" -# + # echo "=============== Running dsmsingle for ${BM_NAME} on 1 machines =================" # dsmsingle 1 ${BM_DSM} # cd $TOPDIR # echo "=================================================================================" -# + # echo "====================================== Recovery Execution Time =============================" -# for count in 2 4 6 8 +# for count in 2 4 8 # do # echo "------- Running $count threads $BM_NAME recovery on $count machines -----" # runRecovery 1 $count ${BM_NAME} @@ -330,7 +332,7 @@ function testcase { # echo "=================================================================================" # echo "====================================== DSM Execution Time =============================" -# for count in 2 4 6 8 +# for count in 2 4 8 # do # echo "------- Running $count threads $BM_NAME dsm on $count machines -----" # runDSM 1 $count $BM_DSM -- 2.34.1