Skip to content

How to properly reuse free space after clear? #335

@timotejroiko

Description

@timotejroiko

Hi, i have a couple questions about reclaiming free space:

My workload involves generating a dataset of about 500k records which results in ~100mb file size when stored in lmdb. Occasionally i need to update the dataset, and in certain cases it has to be done while the application that uses it is still running.

I tried doing this by running a transaction(() => { clearAsync(); put() 500k times; }) from a separate process, but by doing this, the file grows to ~200mb, and continues to increase by 100mb every time the update script runs.

Is there a proper way to make lmdb priorize reusing free space instead of growing the file, especially when writing after clearing?

these are my current settings:

lmdb.open({
    path: ...,
    noSync: false,
    noMemInit: true,
    remapChunks: true,
    useWritemap: false,
    sharedStructuresKey: Symbol.for("structures"),
    cache: true
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions