I have created /pmem0/ of 4GB out of 16GB RAM.
Why so much difference? It should be near to tmpfs time.
// node for non-volatile memory
struct PNode{
int key;
PNode(){}
PNode(int k):key(k){}
};
// node for volatile memory, each volatile node is connected to a non-volatile node having same key value.
struct Node{
int key;
pobj::persistent_ptr<PNode> pnext; // reference to PNode
atomic<Node*> next; // reference to next Node
Node(){}
Node(int k, pobj::persistent_ptr<PNode> n):key(k),pnext(n),next(nullptr){}
};
void PList :: initList(int seed){ // seed value is 1M
auto pool = pobj::pool_by_vptr(this);
pobj::transaction::run(pool, [this, &seed] {
Node * pred, *curr; // volatile reference
curr = Head; // Head is volatile sentinel node, it is connected with Tail sentinel node using next
pobj::persistent_ptr<PNode> newPNode; // reference for non-volatile node
for(int i=1; i<=seed; i=i+2){
auto newn = pobj::make_persistent<PNode>(i); //allocate new non-volatile node
newPNode = newn;
Node *newv = new Node(i, newPNode); // allocate new volatile node
newv->next = Tail; // insert at the Tail position
curr->next = newv;
curr = newv;
}
});
}
/* handle file creation/open */
std::string path{argv[1]}; // path = "/pmem0/fp"
pmem::obj::pool<root> pop;
if (file_exists(path)) {
pop = pmem::obj::pool<root>::open(path, LAYOUT);
} else {
pop = pmem::obj::pool<root>::create(path, LAYOUT, PMEMOBJ_MIN_POOL * 450, CREATE_MODE_RW); //it creates 3.8GB memory in /pmem0/fp
/* allocate the persistent plist only when the pool is new */
pmem::obj::make_persistent_atomic<PList>(pop, pop.root()->plist);
pop.root()->plist->initList(seed); // initList method is invoked here
}