Skip to content

Buffers, Copying and Reuse #81

Description

@jbee

This is a pure question to get my understanding straight.

In connection with LMDB the is talk about zero copying.
My understanding would be that one can use a off-heap buffer that points directly at the memory LMDB uses for a key or value. In a read-only case we would not have to copy such a buffer for reading from it. The Java class handling it would have that pointer and some fields for the position etcetera. What about writing? Is there any coping? Why not?

Netty and Agrona provide such a buffers. What is the minimal way to use one of these? Copy code from somewhere?

If on the other hand one uses a JRE DirectByteBuffer we allocate off-heap memory and the key or value is copied from LMDBs memory into the allocated memory or vice versa.

If that is correct I got the idea that I can have a single JRE buffer allocated for values when writing that I reuse all the time since there only could be one thread writing at a time anyway. Is this good practice or a bad idea? If so why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions