From 40286e4192d4d08913d829e887dc22e2c2f84fda Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 7 Jul 2020 15:29:16 +0200 Subject: [PATCH] Use mostly defaults for badger options This options are the defults in badger `master` now. We should update to next badger version as soon as it is stable, it has some nice improvments. Signed-off-by: Jakub Sztandera --- go.mod | 1 + go.sum | 4 ++++ node/repo/fsrepo_ds.go | 11 +++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 1591639e5..f6fe499cd 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect github.com/coreos/go-systemd/v22 v22.0.0 + github.com/dgraph-io/badger/v2 v2.0.3 github.com/docker/go-units v0.4.0 github.com/drand/drand v0.9.2-0.20200616080806-a94e9c1636a4 github.com/drand/kyber v1.1.0 diff --git a/go.sum b/go.sum index 0f334363a..ef8f4fcf2 100644 --- a/go.sum +++ b/go.sum @@ -167,11 +167,15 @@ github.com/dgraph-io/badger v1.6.0-rc1/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhY github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgraph-io/badger v1.6.1 h1:w9pSFNSdq/JPM1N12Fz/F/bzo993Is1W+Q7HjPzi7yg= github.com/dgraph-io/badger v1.6.1/go.mod h1:FRmFw3uxvcpa8zG3Rxs0th+hCLIuaQg8HlNV5bjgnuU= +github.com/dgraph-io/badger/v2 v2.0.1-0.20200702101623-717b89c860d0 h1:PnKd62IRAlWgoXvYPtTVckAv3+gpo7XZdpjD0cxvdsA= +github.com/dgraph-io/badger/v2 v2.0.1-0.20200702101623-717b89c860d0/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/badger/v2 v2.0.3 h1:inzdf6VF/NZ+tJ8RwwYMjJMvsOALTHYdozn0qSl6XJI= github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM= github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de h1:t0UHb5vdojIDUqktM6+xJAfScFBsVpXZmqC9dsgJmeA= +github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= diff --git a/node/repo/fsrepo_ds.go b/node/repo/fsrepo_ds.go index 034635c4f..3c536a45d 100644 --- a/node/repo/fsrepo_ds.go +++ b/node/repo/fsrepo_ds.go @@ -1,16 +1,18 @@ package repo import ( + "os" + "path/filepath" + "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/mount" "github.com/ipfs/go-datastore/namespace" "golang.org/x/xerrors" - "os" - "path/filepath" + dgbadger "github.com/dgraph-io/badger/v2" badger "github.com/ipfs/go-ds-badger2" levelds "github.com/ipfs/go-ds-leveldb" - "github.com/ipfs/go-ds-measure" + measure "github.com/ipfs/go-ds-measure" ldbopts "github.com/syndtr/goleveldb/leveldb/opt" ) @@ -25,7 +27,8 @@ var fsDatastores = map[string]func(path string) (datastore.Batching, error){ func badgerDs(path string) (datastore.Batching, error) { opts := badger.DefaultOptions - opts.Truncate = true + opts.Options = dgbadger.DefaultOptions("").WithCompactL0OnClose(false). + WithTruncate(true).WithValueThreshold(1 << 10) return badger.NewDatastore(path, &opts) }