Categorygithub.com/to4yokoyama/go-mdbm
modulepackage
0.1.2
Repository: https://github.com/to4yokoyama/go-mdbm.git
Documentation: pkg.go.dev

# README

Go-mdbm

  • Go-mdbm is a Go(golang,go-lang) binds to Yahoo! MDBM C API.
  • MDBM is a super-fast memory-mapped key/value store.
  • MDBM is an ndbm work-alike hashed database library based on sdbm which is based on Per-Aake Larson’s Dynamic Hashing algorithms.
  • MDBM is a high-performance, memory-mapped hash database similar to the homegrown libhash.
  • The records stored in a mdbm database may have keys and values of arbitrary and variable lengths.

Build Status Go Report Card GoDoc Coverage Status Go Walker GitHub version License: MIT

Table of Contents

Install from Source Code

Y! MDBM

Downloading

Use the master branch

git clone https://github.com/yahoo/mdbm.git

OR Use the release tarball, Guess you will using it

wget https://github.com/yahoo/mdbm/archive/v4.12.3.tar.gz
tar xvzf v4.12.3.tar.gz

Compiling

Refer to the https://github.com/yahoo/mdbm/blob/master/README.build if you want to install to another path, (HIGH RECOMMEND)

cd mdbm
PREFIX=/usr/local/mdbm make install

Install from Pre-build Packages

Ubuntu

dpkg -i pkg/ubunt/mdbm-XXXX_XXXX.dep
echo "/usr/local/mdbm/lib64/" >> /etc/ld.so.conf

go-mdbm

Install

CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" \
CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm" \
go get github.com/torden/go-mdbm

Download for Development or Customization

git clone https://github.com/torden/go-mdbm
Build
cd $GOPATH/src/github.com/torden/go-mdbm

make clean
make setup
make build
Testing
cd $GOPATH/src/github.com/torden/go-mdbm
make test
Run to Example
cd $GOPATH/src/github.com/torden/go-mdbm/example/
go run -race example.go
Miscellaneous

The following is support to development

make help
build:             Build the go-mdbm
clean::            Clean-up
cover:             Generate a report about coverage
coveralls::        Send a report of coverage profile to coveralls.io
help::             Show Help
installpkgs::      Install Packages
lint:              Run a LintChecker (Normal)
metalinter::       Install GoMetaLinter
pprof:             Profiling
report:            Generate the report for profiling
setup:             Setup Build Environment
strictlint:        Run a LintChecker (Strict)
test:              Run Go Test with Data Race Detection

Support two compatibility branches

BranchSupporttest
masteryesalways
release 4.3.xyestested

Not Support APIs

Unfortunately, the following list is not supported on now. If you want them, please feel free to raise an issue

Deprecated APIs

APISTATUSCOMMENT
mdbm_saveDEPRECATEDmdbm_save is only supported for V2 MDBMs.
mdbm_restoreDEPRECATEDmdbm_restore is only supported for V2 MDBMs.
mdbm_sethashDEPRECATEDLegacy version of mdbm_set_hash() This function has inconsistent naming, an error return value. It will be removed in a future version.

Only a V2 implementation

APISTATUSCOMMENT
mdbm_stat_all_pageV3 not supportedThere is only a V2 implementation. V3 not currently supported.
mdbm_stat_headerV3 not supportedThere is only a V2 implementation. V3 not currently supported.

Alternative

APICOMMENT
mdbm_fetch_bufFetch, FetchStr APIs

As soon

APISTATUS
mdbm_set_backingstoreas soon
mdbm_cdbdump_add_recordas soon
mdbm_cdbdump_importas soon
mdbm_dbdump_to_fileas soon
mdbm_dbdump_trailer_and_closeas soon
mdbm_dbdump_export_headeras soon
mdbm_iterateas soon
mdbm_pruneas soon
mdbm_set_stats_funcas soon
mdbm_chunk_iterateas soon

Examples

See the Documentations for more details

Benchmark

The following is result of Go-mdbm vs BoltDB benchmarks for simple data storing and random fetching in them.

Spec

TypeSpec
MachineVM(VirtualBox)
OSUbuntu 17.10 (Artful Aardvark)
CPU2 vCore
RAM8G
BoltDB Ver.9da3174 on 20 Nov
Mdbm Ver.893f7a8 on 26 Jul

Command

CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm" \
go test -race -bench=. -run Benchmark -test.benchmem -v

Output

funccount of loopnano-seconds per loopbytes per operationallocations per operation
Benchmark_boltdb_Store-220001082487 ns/op38110 B/op59 allocs/op
Benchmark_mdbm_Store-25000002845 ns/op96 B/op6 allocs/op
Benchmark_mdbm_StoreWithLock-25000002908 ns/op96 B/op6 allocs/op
Benchmark_boltdb_Fetch-22000009199 ns/op496 B/op9 allocs/op
Benchmark_mdbm_Fetch-210000001824 ns/op56 B/op4 allocs/op
Benchmark_mdbm_FetchWithLock-210000002025 ns/op56 B/op4 allocs/op
Benchmark_mdbm_PreLoad_Fetch-210000001811 ns/op56 B/op4 allocs/op
Benchmark_mdbm_PreLoad_FetchWithLock-25000002038 ns/op56 B/op4 allocs/op

Additional Benchmarks

Spec

TypeSpec
MachineVM(VirtualBox)
OSUbuntu 17.10 (Artful Aardvark)
CPU2 vCore
RAM8G
BoltDB Ver.9da3174 on 20 Nov
Mdbm Ver.893f7a8 on 26 Jul

Command

CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm"
go test -race -bench=. -run Benchmark -test.benchmem -v \
Output
Benchmark_boltdb_Store-2                            2000           1072628 ns/op           37994 B/op         59 allocs/op
Benchmark_boltdb_Fetch-2                          200000              8960 ns/op             496 B/op          9 allocs/op
Benchmark_mdbm_Store-2                            500000              2923 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_StoreWithLock-2                    500000              3055 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_Fetch-2                           1000000              1823 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_FetchWithLock-2                   1000000              2093 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_Fetch-2                   1000000              1825 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_FetchWithLock-2            500000              2084 ns/op              56 B/op          4 allocs/op
DB File
TypeFile SizeTimeselapsed time
BoltDB128K100001168516ns
MDBM(Store)32M30000002937ns

Command

CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm" \
go test -race -bench=. -run Benchmark -test.benchmem -v -test.benchtime 3s
Output
Benchmark_boltdb_Store-2                            5000           1168516 ns/op           39249 B/op         59 allocs/op
Benchmark_boltdb_Fetch-2                          500000              9146 ns/op             496 B/op          9 allocs/op
Benchmark_mdbm_Store-2                           2000000              2937 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_StoreWithLock-2                   1000000              3015 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_Fetch-2                           2000000              1891 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_FetchWithLock-2                   2000000              2185 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_Fetch-2                   2000000              1975 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_FetchWithLock-2           2000000              2129 ns/op              56 B/op          4 allocs/op
DB File
TypeFile SizeTimeselapsed time
BoltDB256K100001168516ns
MDBM(Store)128M30000002937ns

Command

CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm" \
go test -race -bench=. -run Benchmark -test.benchmem -v -test.benchtime 10s
Output
Benchmark_boltdb_Store-2                           10000           1115691 ns/op           41109 B/op         60 allocs/op
Benchmark_mdbm_Store-2                           5000000              2933 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_StoreWithLock-2                   5000000              3098 ns/op              96 B/op          6 allocs/op
Benchmark_boltdb_Fetch-2                         2000000              9200 ns/op             496 B/op          9 allocs/op
Benchmark_mdbm_Fetch-2                          10000000              1802 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_FetchWithLock-2                  10000000              2049 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_Fetch-2                  10000000              1802 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_FetchWithLock-2          10000000              2038 ns/op              56 B/op          4 allocs/op
DB File
TypeFile SizeTimeselapsed time
BoltDB512K100001115691ns
MDBM(Store)257M50000002933ns

Spec

TypeSpec
MachinePhysical
OSUbuntu 17.10 (Artful Aardvark)
CPU8 Core (Intel i7)
RAM16G
HDDSSD
BoltDB Ver.9da3174 on 20 Nov
Mdbm Ver.893f7a8 on 26 Jul

Command

#CPU : 8core
#RAM : 16g
CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm" \
go test -race -bench=. -run Benchmark -test.benchmem -v
Output
Benchmark_boltdb_Store-8                             300           6138312 ns/op           32704 B/op         55 allocs/op
Benchmark_mdbm_Store-8                            200000              5235 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_StoreWithLock-8                    200000              5749 ns/op              96 B/op          6 allocs/op
Benchmark_boltdb_Fetch-8                          100000             15322 ns/op             496 B/op          9 allocs/op
Benchmark_mdbm_Fetch-8                            500000              2852 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_FetchWithLock-8                    300000              3713 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_Fetch-8                    500000              2829 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_FetchWithLock-8            500000              3436 ns/op              56 B/op          4 allocs/op
DB File
TypeFile SizeTimeselapsed time
BoltDB64K3006138312ns
MDBM(Store)16M2000005235ns

Command

CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm" \
go test -race -bench=. -run Benchmark -test.benchmem -v -test.benchtime 3s
Output
Benchmark_boltdb_Store-8                            1000           6283664 ns/op           37533 B/op         58 allocs/op
Benchmark_mdbm_Store-8                           1000000              4780 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_StoreWithLock-8                   1000000              5360 ns/op              96 B/op          6 allocs/op
Benchmark_boltdb_Fetch-8                          300000             14556 ns/op             496 B/op          9 allocs/op
Benchmark_mdbm_Fetch-8                           2000000              2772 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_FetchWithLock-8                   1000000              3104 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_Fetch-8                   2000000              2527 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_FetchWithLock-8           1000000              3256 ns/op              56 B/op          4 allocs/op
DB File
TypeFile SizeTimeselapsed time
BoltDB128K10006283664ns
MDBM(Store)64M10000004780ns

Command

CGO_CFLAGS="-I/usr/local/mdbm/include/ -I./" CGO_LDFLAGS="-L/usr/local/mdbm/lib64/ -Wl,-rpath=/usr/local/mdbm/lib64/ -lmdbm" \
go test -race -bench=. -run Benchmark -test.benchmem -v -test.benchtime 10s
Output
Benchmark_boltdb_Store-8                            2000           6133872 ns/op           28366 B/op         59 allocs/op
Benchmark_mdbm_Store-8                           3000000              5377 ns/op              96 B/op          6 allocs/op
Benchmark_mdbm_StoreWithLock-8                   3000000              5145 ns/op              96 B/op          6 allocs/op
Benchmark_boltdb_Fetch-8                         1000000             15703 ns/op             496 B/op          9 allocs/op
Benchmark_mdbm_Fetch-8                           5000000              2631 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_FetchWithLock-8                   5000000              3245 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_Fetch-8                   5000000              2598 ns/op              56 B/op          4 allocs/op
Benchmark_mdbm_PreLoad_FetchWithLock-8           5000000              3379 ns/op              56 B/op          4 allocs/op
DB File
TypeFile SizeTimeselapsed time
BoltDB128K20006133872ns
MDBM(Store)256M30000005377ns

Links


Please feel free. I hope it is helpful for you

# Packages

No description provided by the author