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 5509363..109e8d8 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 a1dcad5..dadb759 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++) {