[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Using sendfile with lmdb
- To: openldap-devel@openldap.org
- Subject: Using sendfile with lmdb
- From: James Rouzier <rouzier@gmail.com>
- Date: Mon, 30 Mar 2015 22:12:01 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=xKVCx8+Tu3DXodnpEP7Xx4EmtQQGA7AANQ1ujylUAcQ=; b=cCYuEtMZA7sX+baTBvhIigiXljv4jevKyDV09gq7kFNa20yLi46F51eSYqX/BOVzIt 28Uvwa3A/3kFw8BydijR+AR8o1bGvzIOPzvA5glj7QyMdfqxGI5K00iiVdIA50hjncAK O3Hh4PAjBlcJG51OgHppuxeGbV56zVvSfVxkkd2o/RlnKrNZ+HTUmsQu0KrHyqLi4jN0 x8qwTZodz809HV/MNCxHkq2L+Sy9pJeJknowHGpHyGPpYQuYTULDttfqjhMrispNVTgn ltQxYDLhTQh0pcTyFvyeAug/FjRt2Ro/3rbr8yn3FmVGArqUATao1kOQjdUYDwf3tvad Y5KA==
Hey Guys,
I am working on a proof of concept of a simple key value store service using lmdb as the back end.
I am using sendfile to avoid an extra copy.
I accomplished this by creating function to extract get the mmap ptr from the env so I can calculate the offset of data.
I figured that function might be useful to the bigger community.
If it does not fit in the bigger vision of lmdb it is fine not to include it.
You will find the diff attached.
diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h
index 736d190..f71df3c 100644
--- a/libraries/liblmdb/lmdb.h
+++ b/libraries/liblmdb/lmdb.h
@@ -819,6 +819,18 @@ int mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *fd);
*/
int mdb_env_set_mapsize(MDB_env *env, size_t size);
+ /** @brief Get the current mmap pointer
+ *
+ * @param[in] env An environment handle returned by #mdb_env_create()
+ * @param[out] The address of the pointer to store mmap prt
+ * @return A non-zero error value on failure and 0 on success. Some possible
+ * errors are:
+ * <ul>
+ * <li>EINVAL - an invalid parameter was specified.
+ * </ul>
+ */
+int mdb_env_get_mmap_ptr(MDB_env *env, char **mmap_ptr);
+
/** @brief Set the maximum number of threads/reader slots for the environment.
*
* This defines the number of slots in the lock table that is used to track readers in the
diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
index 213842a..33c05c5 100644
--- a/libraries/liblmdb/mdb.c
+++ b/libraries/liblmdb/mdb.c
@@ -3932,6 +3932,16 @@ mdb_env_set_mapsize(MDB_env *env, size_t size)
}
int ESECT
+mdb_env_get_mmap_ptr(MDB_env *env, char **arg)
+{
+ if (!env || !arg)
+ return EINVAL;
+
+ *arg = env->me_map;
+ return MDB_SUCCESS;
+}
+
+int ESECT
mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs)
{
if (env->me_map)