Use NoSync with bolt storage and piece completion
Fixes terrible slowness on Linux.
This commit is contained in:
parent
6239a83bd6
commit
09218898e9
@ -35,6 +35,7 @@ func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
db.NoSync = true
|
||||
ret = &boltPieceCompletion{db}
|
||||
return
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user