From 09218898e9fed0bac9c1dbc492dd34de3672d43b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 9 Jan 2018 23:11:34 +1100 Subject: [PATCH] Use NoSync with bolt storage and piece completion Fixes terrible slowness on Linux. --- storage/boltPieceCompletion.go | 1 + storage/boltdb.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/storage/boltPieceCompletion.go b/storage/boltPieceCompletion.go index 93cf8d6f..d0accb1d 100644 --- a/storage/boltPieceCompletion.go +++ b/storage/boltPieceCompletion.go @@ -35,6 +35,7 @@ func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error) { if err != nil { return } + db.NoSync = true ret = &boltPieceCompletion{db} return } diff --git a/storage/boltdb.go b/storage/boltdb.go index 6c8de430..6586ff0e 100644 --- a/storage/boltdb.go +++ b/storage/boltdb.go @@ -3,7 +3,9 @@ package storage import ( "encoding/binary" "path/filepath" + "time" + "github.com/anacrolix/missinggo/assert" "github.com/boltdb/bolt" "github.com/anacrolix/torrent/metainfo" @@ -25,13 +27,12 @@ type boltDBTorrent struct { } func NewBoltDB(filePath string) ClientImpl { - ret := &boltDBClient{} - var err error - ret.db, err = bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, nil) - if err != nil { - panic(err) - } - return ret + db, err := bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, &bolt.Options{ + Timeout: time.Second, + }) + assert.Nil(err) + db.NoSync = true + return &boltDBClient{db} } func (me *boltDBClient) Close() error { -- 2.48.1