diff --git a/src/ee/anticache/AntiCacheDB.cpp b/src/ee/anticache/AntiCacheDB.cpp index e196529a87..8a8febcffc 100644 --- a/src/ee/anticache/AntiCacheDB.cpp +++ b/src/ee/anticache/AntiCacheDB.cpp @@ -100,6 +100,8 @@ void AntiCacheDB::initializeNVM() { strcpy(nvm_file_name, m_dbDir.c_str()); strcat(nvm_file_name, "/anticache.nvm"); + nvm_file = fopen(nvm_file_name, "w"); + fclose(nvm_file); nvm_file = fopen(nvm_file_name, "rw+"); if(nvm_file == NULL) @@ -125,13 +127,20 @@ void AntiCacheDB::initializeNVM() { } m_NVMBlocks = (char*)mmap(NULL, NVM_FILE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, nvm_fd, 0); - + //m_NVMBlocks = new char[NVM_FILE_SIZE]; + if(m_NVMBlocks == MAP_FAILED) { VOLT_ERROR("Anti-Cache initialization error."); VOLT_ERROR("Failed to mmap PMFS file %s: %s", nvm_file_name, strerror(errno)); throwFatalException("Failed to initialize anti-cache PMFS file in directory %s.", m_dbDir.c_str()); } + + // write out NULL characters to ensure entire file has been fetchted from memory + for(int i = 0; i < NVM_FILE_SIZE; i++) + { + m_NVMBlocks[i] = '\0'; + } } void AntiCacheDB::shutdownBerkeleyDB() { @@ -162,7 +171,6 @@ void AntiCacheDB::shutdownNVM() { } - AntiCacheDB::~AntiCacheDB() { #ifdef ANTICACHE_NVM @@ -232,7 +240,7 @@ void AntiCacheDB::writeBlockNVM(const std::string tableName, //m_NVMBlocks[m_totalBlocks] = new char[size]; //memcpy(m_NVMBlocks[m_totalBlocks], data, size); - VOLT_DEBUG("Writing NVM Block: ID = %d, index = %d, size = %ld", blockId, index, size); + VOLT_INFO("Writing NVM Block: ID = %d, index = %d, size = %ld", blockId, index, size); m_blockMap.insert(std::pair >(blockId, std::pair(index, size))); } @@ -249,7 +257,7 @@ AntiCacheBlock AntiCacheDB::readBlockNVM(std::string tableName, int16_t blockId) } int blockIndex = itr->second.first; - VOLT_DEBUG("Reading NVM block: ID = %d, index = %d, size = %ld.", blockId, blockIndex, itr->second.second); + VOLT_INFO("Reading NVM block: ID = %d, index = %d, size = %ld.", blockId, blockIndex, itr->second.second); char* block_ptr = getNVMBlock(blockIndex); AntiCacheBlock block(blockId, empty, block_ptr, itr->second.second); @@ -280,21 +288,28 @@ AntiCacheBlock AntiCacheDB::readBlock(std::string tableName, int16_t blockId) { } void AntiCacheDB::flushBlocks() { - m_db->sync(0); + + #ifdef ANTICACHE_NVM + + #else + m_db->sync(0); + #endif } char* AntiCacheDB::getNVMBlock(int index) { - char* nvm_block = new char[NVM_BLOCK_SIZE]; - memcpy(nvm_block, m_NVMBlocks+(index*NVM_BLOCK_SIZE), NVM_BLOCK_SIZE); + //char* nvm_block = new char[NVM_BLOCK_SIZE]; + //memcpy(nvm_block, m_NVMBlocks+(index*NVM_BLOCK_SIZE), NVM_BLOCK_SIZE); - return nvm_block; + //return nvm_block; + return (m_NVMBlocks+(index*NVM_BLOCK_SIZE)); } int AntiCacheDB::getFreeNVMBlockIndex() { int free_index = 0; - if(m_NVMBlockFreeList.size() > 0) + //if(m_NVMBlockFreeList.size() > 0) + if(false) { free_index = m_NVMBlockFreeList.back(); } diff --git a/src/ee/anticache/AntiCacheDB.h b/src/ee/anticache/AntiCacheDB.h index 19336a26f5..da5c26110c 100644 --- a/src/ee/anticache/AntiCacheDB.h +++ b/src/ee/anticache/AntiCacheDB.h @@ -117,7 +117,7 @@ class AntiCacheDB { * NVM constants */ static const off_t NVM_FILE_SIZE = 1073741824; - static const int NVM_BLOCK_SIZE = 4096; + static const int NVM_BLOCK_SIZE = 524288 * 2; ExecutorContext *m_executorContext; string m_dbDir; diff --git a/src/ee/storage/persistenttable.cpp b/src/ee/storage/persistenttable.cpp index 5f2a1e168d..4e9dff1005 100644 --- a/src/ee/storage/persistenttable.cpp +++ b/src/ee/storage/persistenttable.cpp @@ -465,7 +465,7 @@ bool PersistentTable::mergeUnevictedTuples() m_unevictedBlocks.clear(); m_mergeTupleOffset.clear(); - m_unevictedBlockIDs.clear(); // if we uncomment this the benchmark won't end + //m_unevictedBlockIDs.clear(); // if we uncomment this the benchmark won't end #ifdef VOLT_INFO_ENABLED VOLT_INFO("Active Tuple Count: %d -- %d", (int)active_tuple_count, (int)activeTupleCount()); diff --git a/src/ee/storage/persistenttable.h b/src/ee/storage/persistenttable.h index 9b31fbfc01..80adc66728 100644 --- a/src/ee/storage/persistenttable.h +++ b/src/ee/storage/persistenttable.h @@ -340,8 +340,8 @@ class PersistentTable : public Table { std::vector m_unevictedBlocks; std::vector m_mergeTupleOffset; - std::map m_unevictedTuplesPerBlocks; - + std::map m_unevictedTuplesPerBlocks; + char* m_unevictedTuples; int m_numUnevictedTuples;