git » nmdb » commit c72b059

Reduce do_get() malloc() size.

author Alberto Bertogli
2007-01-08 05:11:56 UTC
committer Alberto Bertogli
2007-01-08 05:11:56 UTC
parent 31e286a71d2735d73bd77bed1cf07263d720083b

Reduce do_get() malloc() size.
Instead of doing malloc(128k) do malloc(70k) which is more appropriate given
the max size of a TIPC packet (66000 bytes).

This speed get operations up considerably, for instance for
"./test1c 20000 k v" and "./test2c 20000 4 4":

	malloc(128k)	malloc(70k)
test1c	536426		376679
test2c	520247		381682

Now performance fits better with the expectations from the code analysis.

libnmdb/libnmdb.c +2 -2

diff --git a/libnmdb/libnmdb.c b/libnmdb/libnmdb.c
index 36c3155..ceb7b05 100644
--- a/libnmdb/libnmdb.c
+++ b/libnmdb/libnmdb.c
@@ -230,9 +230,9 @@ static ssize_t do_get(nmdb_t *db,
 	 * 		vsize bytes key.
 	 *
 	 * We don't know vsize beforehand, but we do know TIPC's max packet is
-	 * 66000. We malloc 128k just in case.
+	 * 66000. We malloc 70k just in case.
 	 */
-	bsize = 128 * 1024;
+	bsize = 70 * 1024;
 	buf = malloc(bsize);
 	if (buf == NULL)
 		return -1;