From 9924fa3b1a291ac6efe856619cfe98e21900ae87 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 9 Apr 2019 00:24:32 -0700 Subject: [PATCH] weed volume: disable block cache on leveldb saving 8MB for each volume, but at the cost of slower lookup --- weed/storage/needle_map_leveldb.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weed/storage/needle_map_leveldb.go b/weed/storage/needle_map_leveldb.go index 939e0cac4..c5c4f22eb 100644 --- a/weed/storage/needle_map_leveldb.go +++ b/weed/storage/needle_map_leveldb.go @@ -2,6 +2,7 @@ package storage import ( "fmt" + "github.com/syndtr/goleveldb/leveldb/opt" "os" "path/filepath" @@ -27,7 +28,9 @@ func NewLevelDbNeedleMap(dbFileName string, indexFile *os.File) (m *LevelDbNeedl glog.V(0).Infof("Finished Generating %s from %s", dbFileName, indexFile.Name()) } glog.V(1).Infof("Opening %s...", dbFileName) - if m.db, err = leveldb.OpenFile(dbFileName, nil); err != nil { + if m.db, err = leveldb.OpenFile(dbFileName, &opt.Options{ + BlockCacheCapacity: -1, // default value is 8MiB + }); err != nil { return } glog.V(1).Infof("Loading %s...", indexFile.Name())