Giter VIP home page Giter VIP logo

pmemkv's Introduction

pmemkv

Key/Value Datastore for Persistent Memory

This is experimental pre-release software and should not be used in production systems. APIs and file formats may change at any time without preserving backwards compatibility. All known issues and limitations are logged as GitHub issues.

Overview

pmemkv is a local/embedded key-value datastore optimized for persistent memory. Rather than being tied to a single language or backing implementation, pmemkv provides different options for storage engines and language bindings.

Storage Engines

pmemkv provides multiple storage engines with vastly different implementations. Since all engines conform to the same common API, any engine can be used with common pmemkv utilities and language bindings. Engines are requested at runtime by name. Contributing a new engine is easy and encouraged!

pmemkv-engines

Available Engines

Engine Description Thread-Safe?
kvtree2 (default) Hybrid B+ persistent tree (latest version) No
kvtree Hybrid B+ persistent tree (2017 version) No
blackhole Accepts everything, returns nothing Yes

Language Bindings

pmemkv is written in C and C++. Developers can either use native C++ classes directly, or use our extern "C" API, or use one of several high-level language bindings that are based on the extern "C" API.

pmemkv-bindings

C++

#include <libpmemkv.h>
#include <string.h>
#include <assert.h>
using namespace pmemkv;

int main() {
    // open the datastore
    KVEngine* kv = new KVEngine("kvtree2", "/dev/shm/mykv", 8388608);  // 8 MB

    // put new key
    KVStatus s = kv->Put("key1", "value1");
    assert(s == OK);

    // read last key back
    string value;
    s = kv->Get("key1", &value);
    assert(s == OK && value == "value1");

    // close the datastore
    delete kv;

    return 0;
}

C

#include <libpmemkv.h>
#include <string.h>
#include <assert.h>

int main() {
    #define VAL_LEN 64
    char value[VAL_LEN];

    /* open the datastore */
    KVEngine* kv = kvengine_open("kvtree2", "/dev/shm/mykv", 8388608);

    /* put new key */
    int32_t len = strlen("value1");
    KVStatus s = kvengine_put(kv, "key1", "value1", &len);
    assert(s == OK);

    /* read last key back */
    len = VAL_LEN;
    s = kvengine_get(kv, "key1", VAL_LEN, value, &len);
    assert(s == OK && !strcmp(value, "value1"));

    /* close the datastore */
    kvengine_close(kv);

    return 0;
}

Other Languages

These bindings are maintained in separate GitHub repos, but are still kept in sync with the main pmemkv distribution.

Benchmarking

The pmemkv_bench utility provides some simple read & write benchmarks. This is much like the db_bench utility included with LevelDB and RocksDB, although the list of supported parameters is slightly different.

pmemkv_bench
--engine=<name>            (storage engine name, default: kvtree2)
--db=<location>            (path to persistent pool, default: /dev/shm/pmemkv)
                           (note: file on DAX filesystem, DAX device, or poolset file)
--db_size_in_gb=<integer>  (size of persistent pool to create in GB, default: 0)
                           (note: always use 0 with poolset or device DAX configs)
--histogram=<0|1>          (show histograms when reporting latencies)
--num=<integer>            (number of keys to place in database, default: 1000000)
--reads=<integer>          (number of read operations, default: 1000000)
--threads=<integer>        (number of concurrent threads, default: 1)
--value_size=<integer>     (size of values in bytes, default: 100)
--benchmarks=<name>,       (comma-separated list of benchmarks to run)
    fillseq                (load N values in sequential key order)
    fillrandom             (load N values in random key order)
    overwrite              (replace N values in random key order)
    readseq                (read N values in sequential key order)
    readrandom             (read N values in random key order)
    readmissing            (read N missing values in random key order)
    deleteseq              (delete N values in sequential key order)
    deleterandom           (delete N values in random key order)

Benchmarking on emulated persistent memory:

PMEM_IS_PMEM_FORCE=1 ./bin/pmemkv_bench --db=/dev/shm/pmemkv --db_size_in_gb=1

Benchmarking on filesystem DAX:

PMEM_IS_PMEM_FORCE=1 ./bin/pmemkv_bench --db=/mnt/pmem/pmemkv --db_size_in_gb=1

Benchmarking on device DAX:

./bin/pmemkv_bench --db=/dev/dax1.0

Benchmarking with poolset:

PMEM_IS_PMEM_FORCE=1 ./pmemkv_bench --db=~/pmemkv.poolset

pmemkv's People

Contributors

robdickinson avatar gbuella avatar xuning97 avatar yuelimv avatar marcinslusarz avatar roblatham00 avatar vinser52 avatar kfilipek avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.