]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Use NoSync with bolt storage and piece completion
authorMatt Joiner <anacrolix@gmail.com>
Tue, 9 Jan 2018 12:11:34 +0000 (23:11 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 9 Jan 2018 12:11:34 +0000 (23:11 +1100)
Fixes terrible slowness on Linux.

storage/boltPieceCompletion.go
storage/boltdb.go

index 93cf8d6f666da0a033201edb958841028c694365..d0accb1df7da225184616b8cd1d68541adeb86b6 100644 (file)
@@ -35,6 +35,7 @@ func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error) {
        if err != nil {
                return
        }
+       db.NoSync = true
        ret = &boltPieceCompletion{db}
        return
 }
index 6c8de430d6ca7aa1e0a596a7d53ba505e3a8fd4e..6586ff0e3c009628554b093f8964bb615d14819c 100644 (file)
@@ -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 {