Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remove content addressable page store
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 17 Jul 2015 09:36:15 +0000 (11:36 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 17 Jul 2015 09:36:15 +0000 (11:36 +0200)
- It did not prove useful compared fo the default option.
- It is implemented as a compile-time option instead of a runtime one.
- Let's remove compile time options!
- It makes the code more complex.

buildtools/Cmake/Flags.cmake
buildtools/Cmake/MakeLib.cmake
buildtools/Cmake/Option.cmake
src/mc/PageStore.cpp
src/mc/PageStore.hpp

index 3fe0a43..7bdf3b0 100644 (file)
@@ -101,11 +101,6 @@ if(enable_model-checking AND enable_compile_optimizations)
   endforeach()
 endif()
 
   endforeach()
 endif()
 
-if(enable_mc_content_adressable_pages)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMC_PAGE_STORE_MD4")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMC_PAGE_STORE_MD4")
-endif()
-
 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
   set(optCFLAGS "-O0 ")
 if(APPLE AND COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
   set(optCFLAGS "-O0 ")
index 838739c..f8d2a4f 100644 (file)
@@ -107,10 +107,6 @@ if(HAVE_GTNETS)
   SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
 endif()
 
   SET(SIMGRID_DEP "${SIMGRID_DEP} -lgtnets")
 endif()
 
-if(enable_mc_content_adressable_pages)
-  SET(SIMGRID_DEP "${SIMGRID_DEP} -lnettle")
-endif()
-
 if(HAVE_MC)
   # The availability of libunwind was checked in CompleteInFiles.cmake
   #   (that includes FindLibunwind.cmake), so simply load it now.
 if(HAVE_MC)
   # The availability of libunwind was checked in CompleteInFiles.cmake
   #   (that includes FindLibunwind.cmake), so simply load it now.
index f92796b..9c01b51 100644 (file)
@@ -38,7 +38,6 @@ option(enable_mallocators "Enable mallocators (disable only for debugging purpos
 option(enable_print_message "Enable print message during config." off)
 mark_as_advanced(enable_print_message)
 option(enable_model-checking "Turn this on to experiment with our prototype of model-checker (hinders the simulation's performance even if turned off at runtime)" off)
 option(enable_print_message "Enable print message during config." off)
 mark_as_advanced(enable_print_message)
 option(enable_model-checking "Turn this on to experiment with our prototype of model-checker (hinders the simulation's performance even if turned off at runtime)" off)
-option(enable_mc_content_adressable_pages "Content addressable page storage (rely on the hash of the pages for page snapshot)" off)
 option(enable_lib_static "" off)
 option(enable_lib_in_jar "Whether the native libraries are bundled in a Java jar file" on)
 option(enable_jedule "Jedule output of SimDAG." off)
 option(enable_lib_static "" off)
 option(enable_lib_in_jar "Whether the native libraries are bundled in a Java jar file" on)
 option(enable_jedule "Jedule output of SimDAG." off)
index 05df2a8..e8c74ac 100644 (file)
 
 #include "PageStore.hpp"
 
 
 #include "PageStore.hpp"
 
-#ifdef MC_PAGE_STORE_MD4
-#include <nettle/md4.h>
-#endif
-
 #include "mc_mmu.h"
 
 extern "C" {
 #include "mc_mmu.h"
 
 extern "C" {
@@ -40,14 +36,6 @@ namespace mc {
 static inline  __attribute__ ((always_inline))
 PageStore::hash_type mc_hash_page(const void* data)
 {
 static inline  __attribute__ ((always_inline))
 PageStore::hash_type mc_hash_page(const void* data)
 {
-#ifdef MC_PAGE_STORE_MD4
-   boost::array<uint64_t,2> result;
-   md4_ctx context;
-   md4_init(&context);
-   md4_update(&context, xbt_pagesize, (const uint8_t*) data);
-   md4_digest(&context, MD4_DIGEST_SIZE, (uint8_t*) &(result[0]));
-   return result;
-#else
   const uint64_t* values = (const uint64_t*) data;
   size_t n = xbt_pagesize / sizeof(uint64_t);
 
   const uint64_t* values = (const uint64_t*) data;
   size_t n = xbt_pagesize / sizeof(uint64_t);
 
@@ -57,7 +45,6 @@ PageStore::hash_type mc_hash_page(const void* data)
     hash = ((hash << 5) + hash) + values[i];
   }
   return hash;
     hash = ((hash << 5) + hash) + values[i];
   }
   return hash;
-#endif
 }
 
 // ***** snapshot_page_manager
 }
 
 // ***** snapshot_page_manager
@@ -133,11 +120,7 @@ void PageStore::remove_page(size_t pageno)
   this->free_pages_.push_back(pageno);
   const void* page = this->get_page(pageno);
   hash_type hash = mc_hash_page(page);
   this->free_pages_.push_back(pageno);
   const void* page = this->get_page(pageno);
   hash_type hash = mc_hash_page(page);
-#ifdef MC_PAGE_STORE_MD4
-  this->hash_index_.erase(hash);
-#else
   this->hash_index_[hash].erase(pageno);
   this->hash_index_[hash].erase(pageno);
-#endif
 }
 
 /** Store a page in memory */
 }
 
 /** Store a page in memory */
@@ -151,17 +134,6 @@ size_t PageStore::store_page(void* page)
   //  2. find pages with the same hash using `hash_index_`;
   //  3. find a page with the same content.
   hash_type hash = mc_hash_page(page);
   //  2. find pages with the same hash using `hash_index_`;
   //  3. find a page with the same content.
   hash_type hash = mc_hash_page(page);
-#ifdef MC_PAGE_STORE_MD4
-  s_mc_pages_store::pages_map_type::const_iterator i =
-    this->hash_index_.find(hash);
-  if (i!=this->hash_index_.cend()) {
-    // If a page with the same content is already in the page store it is
-    // reused and its reference count is incremented.
-    size_t pageno = i->second;
-    page_counts_[pageno]++;
-    return pageno;
-  }
-#else
 
   // Try to find a duplicate in set of pages with the same hash:
   page_set_type& page_set = this->hash_index_[hash];
 
   // Try to find a duplicate in set of pages with the same hash:
   page_set_type& page_set = this->hash_index_[hash];
@@ -176,7 +148,6 @@ size_t PageStore::store_page(void* page)
 
     }
   }
 
     }
   }
-#endif
 
   // Otherwise, a new page is allocated in the page store and the content
   // of the page is `memcpy()`-ed to this new page.
 
   // Otherwise, a new page is allocated in the page store and the content
   // of the page is `memcpy()`-ed to this new page.
@@ -184,11 +155,7 @@ size_t PageStore::store_page(void* page)
   xbt_assert(this->page_counts_[pageno]==0, "Allocated page is already used");
   void* snapshot_page = (void*) this->get_page(pageno);
   memcpy(snapshot_page, page, xbt_pagesize);
   xbt_assert(this->page_counts_[pageno]==0, "Allocated page is already used");
   void* snapshot_page = (void*) this->get_page(pageno);
   memcpy(snapshot_page, page, xbt_pagesize);
-#ifdef MC_PAGE_STORE_MD4
-  this->hash_index_[hash] = pageno;
-#else
   page_set.insert(pageno);
   page_set.insert(pageno);
-#endif
   page_counts_[pageno]++;
   return pageno;
 }
   page_counts_[pageno]++;
   return pageno;
 }
index f1d84d3..9296a32 100644 (file)
@@ -78,24 +78,13 @@ namespace mc {
  */
 class PageStore {
 public: // Types
  */
 class PageStore {
 public: // Types
-#ifdef MC_PAGE_STORE_MD4
-  typedef boost::array<uint64_t,2> hash_type;
-#else
   typedef uint64_t hash_type;
   typedef uint64_t hash_type;
-#endif
 private: // Types
 private: // Types
-#ifdef MC_PAGE_STORE_MD4
-  // We are using a secure hash to identify a page.
-  // We assume there will not be any collision: we need to map a hash
-  // to a single page index.
-  typedef boost::unordered_map<hash_type, size_t> pages_map_type;
-#else
   // We are using a cheap hash to index a page.
   // We should expect collision and we need to associate multiple page indices
   // to the same hash.
   typedef boost::unordered_set<size_t> page_set_type;
   typedef boost::unordered_map<hash_type, page_set_type> pages_map_type;
   // We are using a cheap hash to index a page.
   // We should expect collision and we need to associate multiple page indices
   // to the same hash.
   typedef boost::unordered_set<size_t> page_set_type;
   typedef boost::unordered_map<hash_type, page_set_type> pages_map_type;
-#endif
 
 private: // Fields:
   /** First page
 
 private: // Fields:
   /** First page