From c80c149893770f4b86b3578a827c6a028985de7f Mon Sep 17 00:00:00 2001 From: Brian Demsky Date: Tue, 2 Oct 2012 14:54:59 -0700 Subject: [PATCH] small hack to optimize our common case for snapshotting and set config option to turn this back on. hack assumes that same pages will be dirty across different executions so just copies them and doesn't reprotect them --- config.h | 6 ++++-- snapshot.cc | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 5509363..109e8d8 100644 --- a/config.h +++ b/config.h @@ -27,9 +27,11 @@ /** 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 diff --git a/snapshot.cc b/snapshot.cc index a1dcad5..dadb759 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -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; pagelastBackingPage; 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; regionlastRegion;region++) { -- 2.34.1