Closed madroach closed 5 years ago
Regarding the perf improvements with f0ee7f5 : I'm not completely surprised, as the patch in question make inlining simpler and remove stuff from the closure environment. Avoiding closure capture in OCaml is often a significant perf boost.
The new version using bigstringaf
looks really nice. Merging!
This pull request includes #9.
It does not yet make use of MDB_RESERVE, since I have not yet merged the changes to the functorial interface.
Performance with this interface exposing db_val as bigarray is better than with CArray, even though my benchmark uses very small 8-byte integers / strings as keys / values
Strangely performance improved yet a bit with commit f0ee7f5, which prepares the interface to support MDB_RESERVE:
The
write
function is passed an allocator, which may simply allocate a bigarray buffer or call amdb_*_put
function withMDB_RESERVE
and wrap the returned memory region in a bigarray. Ifwrite
calls the allocator it is expected to return the allocated bigarray. Ifwrite
doesn't call the allocator it may return any bigarray and will behave likewrite
in the old interface. So when implementing awrite
function, one may simply ignore the allocator or always use the allocator and the library will decide when to use or not to useMDB_RESERVE
.