Libpmem2 and libpmemobj are in two different level library. Libpmem2 is only considering how to keep the data persistent, but application need to consider the power fail and meta data management.
Libpmemobj consider the ACID with the undo/redo log and help you maintain the data, but the performance is not good enough.
Another option is use the storage over AD that’s configure the Pmem as the fast and low latency storage(SSD) and help you store your snapshot. In the current storage over AD, two kernel patches can improve the performance:
[PATCH] ACPI/NFIT: Add no_deepflush param to dynamic control flush operation & [PATCH] BTT: Use dram freelist and remove bflog to otpimize perf can improve your performance.
From: pm...@googlegroups.com <pm...@googlegroups.com>
On Behalf Of S Kannoth
Sent: Thursday, September 8, 2022 4:37 AM
To: pmem <pm...@googlegroups.com>
Subject: Re: When to use pmemobj_persist
Hi Steve,
Thanks for the detailed reply and pointing me out the PMEM programming book :) . I appreciate it.
In fact my usage of PMEM is a little different. It would be great to know your suggestions on my following questions as well.
I have an application which uses classic posix_memalign() function used for allocations. Now I would like to extend the application with snapshotting capability with PMEM in Filesystem DAX mode. It means I need to have an allocator for PMEM which persists my data over application restart. Since my application is distributed, it might need to write to remote PMEM as well. My first consideration was libmemkind. But, I came to know that libmemkind can only be used in volatile mode, so I cannot re-refer the data after restart.
My initial considerations were using the below libraries.
1) libpmemobj and librpmem (for remote read/writes) - Since I see in the github that librpmem is deprecated this ended up being not a choice.
2) libpmem2 and librpma (for remote) - What do you think about this?
I see there are quite a lot difference between the APIs of libpmemobj and libpmem2. Especially with libpmemobj, the use the term pool and store the data in pools, which I do not see with libpmem2, where we use files and memory map them.
I modified the examples from github and created a naive allocator , below. Do you think this is too simple to be an allocator in practocal applcitions? if so what do you think it lacks and what are your suggestions?
...
typedef struct{
struct pmem2_config *cfg;
struct pmem2_map *map;
struct pmem2_source *src;
pmem2_persist_fn persist;
const char* path;
} naive_pmem_desc_t;
void* naive_pmem_malloc(size_t size , naive_pmem_desc_t desc)
{
int fd;
if ((fd = open(desc.path, O_CREAT | O_RDWR)) < 0)
return NULL;
if((pmem2_config_new(&desc.cfg)))
return NULL;
if( posix_fallocate(fd, 0, size ) < 0)
return NULL;
if (pmem2_source_from_fd(&desc.src, fd))
return NULL;
if (pmem2_config_set_required_store_granularity(desc.cfg, PMEM2_GRANULARITY_PAGE))
return NULL;
if (pmem2_map_new(&desc.map, desc.cfg, desc.src))
return NULL;
close(fd);
return pmem2_map_get_address(desc.map);
}
void naive_pmem_free(naive_pmem_desc_t desc)
{
pmem2_map_delete(&desc.map);
pmem2_source_delete(&desc.src);
pmem2_config_delete(&desc.cfg);
// Delete the file
unlink(path)
}
...
Cheers
~Kannoth
--
You received this message because you are subscribed to the Google Groups "pmem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pmem+uns...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pmem/70b94140-c91f-4f60-9f63-b7d0c7bb7fa6n%40googlegroups.com.