Skip to content

Commit ab56f88

Browse files
committed
Allocate "in-space" NVM using Pool.hpp.
1 parent 8f339be commit ab56f88

8 files changed

+58
-13
lines changed

Diff for: src/ee/anticache/NVMEvictedTable.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929

3030
namespace voltdb {
3131

32-
NVMEvictedTable::NVMEvictedTable(ExecutorContext *ctx) : PersistentTable(ctx, false) {
32+
//NVMEvictedTable::NVMEvictedTable(ExecutorContext *ctx) : PersistentTable(ctx, false) {
33+
NVMEvictedTable::NVMEvictedTable(ExecutorContext *ctx, const std::string name) : PersistentTable(ctx, false) {
34+
35+
delete m_pool;
36+
m_pool = new Pool(1024 * 1024 * 1024, 1024, m_executorContext->getDBDir() + "/" + name, true);
3337

3438
}
3539

@@ -52,7 +56,8 @@ const void* NVMEvictedTable::insertNVMEvictedTuple(TableTuple &source) {
5256
m_tupleCount++;
5357

5458
// Then copy the source into the target
55-
m_tmpTarget1.copyForPersistentInsert(source);
59+
//m_tmpTarget1.copyForPersistentInsert(source);
60+
m_tmpTarget1.copyForPersistentInsert(source, m_pool);
5661
m_tmpTarget1.setDeletedFalse();
5762

5863
// Make sure this tuple is marked as evicted, so that we know it is an

Diff for: src/ee/anticache/NVMEvictedTable.h

+32-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "storage/persistenttable.h"
3030
#include "common/executorcontext.hpp"
31+
#include "common/Pool.hpp"
3132

3233

3334
namespace voltdb {
@@ -44,12 +45,38 @@ class NVMEvictedTable : public PersistentTable {
4445

4546
void deleteNVMEvictedTuple(TableTuple source);
4647

47-
48+
4849
protected:
49-
50-
NVMEvictedTable(ExecutorContext *ctx);
51-
52-
};
50+
inline void allocateNextBlock() {
51+
#ifdef MEMCHECK
52+
int bytes = m_schema->tupleLength() + TUPLE_HEADER_SIZE;
53+
#else
54+
int bytes = m_tableAllocationTargetSize;
55+
#endif
56+
57+
char *memory = NULL;
58+
VOLT_WARN("MMAP : PId:: %d Table: %s Bytes:: %d ",
59+
m_executorContext->getPartitionId(), this->name().c_str(), bytes);
60+
61+
memory = (char*)m_pool->allocate(bytes);
62+
63+
VOLT_WARN("MMAP : Table: %s :: Memory Pointer : %p ",
64+
this->name().c_str(), memory);
65+
66+
if (memory == NULL) {
67+
VOLT_ERROR("MMAP : initialization error.");
68+
throwFatalException("Failed to map file.");
69+
}
70+
71+
m_data.push_back(memory);
72+
73+
74+
m_allocatedTuples += m_tuplesPerBlock;
75+
}
76+
77+
//NVMEvictedTable(ExecutorContext *ctx);
78+
NVMEvictedTable(ExecutorContext *ctx, const std::string name);
79+
};
5380
}
5481

5582
#endif

Diff for: src/ee/common/StringRef.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ StringRef::create(size_t size, Pool* dataPool)
2929
if (dataPool != NULL)
3030
{
3131
retval =
32-
new(dataPool->allocate(sizeof(StringRef))) StringRef(size, dataPool);
32+
new StringRef(size, dataPool);
33+
//new(dataPool->allocate(sizeof(StringRef))) StringRef(size, dataPool);
3334
}
3435
else
3536
{

Diff for: src/ee/common/StringRef.h

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ namespace voltdb
5353
char* get();
5454
const char* get() const;
5555

56+
inline bool isUsingPool() {
57+
return m_tempPool;
58+
}
59+
5660
private:
5761
StringRef(std::size_t size);
5862
StringRef(std::size_t size, Pool* dataPool);

Diff for: src/ee/common/executorcontext.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ namespace voltdb {
124124

125125
inline std::string getDBDir() const {
126126
if (m_MMAPDir.empty())
127-
return "/tmp"; // Default : "/tmp"
127+
return "/mnt/pmfs/mmap_file"; // Default : "/tmp"
128+
//return "/tmp"; // Default : "/tmp"
128129
return (m_MMAPDir);
129130
}
130131

Diff for: src/ee/storage/PersistentTableUndoUpdateAction.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ void PersistentTableUndoUpdateAction::release() {
6868
for (std::vector<char*>::iterator i = oldUninlineableColumns.begin();
6969
i != oldUninlineableColumns.end(); i++)
7070
{
71-
StringRef::destroy((StringRef*)(*i));
72-
//delete [] (*i);
71+
//if (!((StringRef*)(*i))->isUsingPool()) {
72+
StringRef::destroy((StringRef*)(*i));
73+
//delete [] (*i);
74+
//}
7375
}
7476
}
7577

Diff for: src/ee/storage/persistenttable.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,11 @@ bool PersistentTable::updateTuple(TableTuple &source, TableTuple &target, bool u
707707
}
708708

709709
/** TODO : Not Using MMAP pool **/
710-
target.copyForPersistentUpdate(source, NULL);
710+
if (!target.isNVMEvicted()) {
711+
target.copyForPersistentUpdate(source, NULL);
712+
} else {
713+
target.copyForPersistentUpdate(source, getNVMEvictedTable()->getPool());
714+
}
711715

712716
ptuua->setNewTuple(target, pool);
713717

Diff for: src/ee/storage/tablefactory.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ Table* TableFactory::getNVMEvictedTable(voltdb::CatalogId databaseId,
224224
TupleSchema* schema,
225225
const std::string* columnNames) {
226226
VOLT_DEBUG("Creating %s", name.c_str());
227-
Table *table = new NVMEvictedTable(ctx);
227+
//Table *table = new NVMEvictedTable(ctx);
228+
Table *table = new NVMEvictedTable(ctx, name);
228229
NVMEvictedTable *pTable = dynamic_cast<NVMEvictedTable*>(table);
229230
pTable->m_indexCount = 0;
230231

0 commit comments

Comments
 (0)