small hack to optimize our common case for snapshotting and set config option to...
authorBrian Demsky <bdemsky@uci.edu>
Tue, 2 Oct 2012 21:54:59 +0000 (14:54 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Tue, 2 Oct 2012 21:54:59 +0000 (14:54 -0700)
hack assumes that same pages will be dirty across different executions so just copies them and doesn't reprotect them

config.h
snapshot.cc

index 55093637a175186bddebb46b9a37b2f3a5117666..109e8d86097ab55c545705f0059c544bb01b9738 100644 (file)
--- a/config.h
+++ b/config.h
 
 /** Snapshotting configurables */
 
-/** If USE_MPROTECT_SNAPSHOT=1, then snapshot by using mmap() and mprotect()
+/** 
+ * If USE_MPROTECT_SNAPSHOT=2, then snapshot by tuned mmap() algorithm
+ * If USE_MPROTECT_SNAPSHOT=1, then snapshot by using mmap() and mprotect()
  * If USE_MPROTECT_SNAPSHOT=0, then snapshot by using fork() */
-#define USE_MPROTECT_SNAPSHOT 0
+#define USE_MPROTECT_SNAPSHOT 2
 
 /** Size of signal stack */
 #define SIGSTACKSIZE 32768
index a1dcad581985ef7f1f9ae663a446a4fb4e5a333d..dadb75956c1f4254c3ecc84d519cd7431a8910af 100644 (file)
@@ -283,6 +283,15 @@ snapshot_id takeSnapshot( ){
  *  @param theID is the snapshot identifier to rollback to.
  */
 void rollBack( snapshot_id theID ){
+#if USE_MPOTECT_SNAPSHOT==2
+       if (snapshotrecord->lastSnapShot==(theID+1)) {
+               for(unsigned int page=snapshotrecord->snapShots[theID].firstBackingPage; page<snapshotrecord->lastBackingPage; page++) {
+                       memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(struct SnapShotPage));
+               }
+               return;
+       }
+#endif
+
 #if USE_MPROTECT_SNAPSHOT
        HashTable< void *, bool, uintptr_t, 4, model_malloc, model_calloc, model_free> duplicateMap;
        for(unsigned int region=0; region<snapshotrecord->lastRegion;region++) {