deephacks/lmdbjni — pull request #4 by batterseapower (2014-06-30 18:41:21+00:00)
Title: Avoid copying in mdb_cursor_get if possible

The funny thing is that even with this change using mdb_cursor_get to do a sequential scan of an entire DB (holding 4 byte keys and values) still costs about 150ns per item.

In comparison my C code doing the same thing costs only 17ns per item -- i.e. using Java costs more than 130ns per item more! In comparison, using mdb_get to implement a sequential scan costs about 720ns per item in Java but 640ns per item in C, a slowdown of only about 80ns.

The number of MDB_val copies being done per iteration is the same in both cases (i.e. 1 in and 1 out for mdb_get and 2 out for mdb_cursor_get), so I'm not sure why Java is being penalised so much more for the mdb_cursor_get case than it is when doing a mdb_get.