From: Matt Joiner Date: Tue, 9 Jan 2018 12:11:34 +0000 (+1100) Subject: Use NoSync with bolt storage and piece completion X-Git-Tag: v1.0.0~286 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=09218898e9fed0bac9c1dbc492dd34de3672d43b;p=btrtrc.git Use NoSync with bolt storage and piece completion Fixes terrible slowness on Linux. --- 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 {