Permalink
Browse files

More fixes to anti-cache NVM backend.

  • Loading branch information...
jdebrabant committed Oct 6, 2013
1 parent b9b2a68 commit 8cf939d6d870d09db36eff402007e9963e70f45e
@@ -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<int16_t, std::pair<int, long> >(blockId, std::pair<int, long>(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();
}
@@ -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;
@@ -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());
@@ -340,8 +340,8 @@ class PersistentTable : public Table {
std::vector<char*> m_unevictedBlocks;
std::vector<int32_t> m_mergeTupleOffset;
std::map<int, int> m_unevictedTuplesPerBlocks;
std::map<int, int> m_unevictedTuplesPerBlocks;
char* m_unevictedTuples;
int m_numUnevictedTuples;

0 comments on commit 8cf939d

Please sign in to comment.