Current implementation of libpmemobj-cpp is based on persistent_ptr which is in fact a fat pointer. It stores PMEMoid which consists of two 64 bit fileds: pool_uuid and offset. Every dereference of peristent_ptr requires a call to pmemobj_direct function which calculates real address based on PMEMoid. Because of the nature of pmemobj_direct calls to this function cannot be optimized by the compiler and as a result using persistent_ptr is much slower than regular pointers.
Proposal
To address performance problems of peristent_ptr new pointer type with offset addressing model could be introduced. This new type of pointer would have only one 64 bit field: offset. Pointer value would be equal to offset + address of the pointer itself. This pointer would allow compiler to perform much better optimizations as no pmemobj function is required to be called during dereference. Additional benefit over persistent_ptr is smaller size.
The only limitation of this new type of pointer is that it cannot point to objects in another pool.
Rationale
Current implementation of libpmemobj-cpp is based on persistent_ptr which is in fact a fat pointer. It stores
PMEMoid
which consists of two 64 bit fileds:pool_uuid
andoffset
. Every dereference of peristent_ptr requires a call topmemobj_direct
function which calculates real address based onPMEMoid
. Because of the nature ofpmemobj_direct
calls to this function cannot be optimized by the compiler and as a result using persistent_ptr is much slower than regular pointers.Proposal
To address performance problems of peristent_ptr new pointer type with offset addressing model could be introduced. This new type of pointer would have only one 64 bit field: offset. Pointer value would be equal to
offset
+address
of the pointer itself. This pointer would allow compiler to perform much better optimizations as no pmemobj function is required to be called during dereference. Additional benefit over persistent_ptr is smaller size.The only limitation of this new type of pointer is that it cannot point to objects in another pool.