2
0
mirror of synced 2025-02-24 06:38:14 +00:00

Use NoSync with bolt storage and piece completion

Fixes terrible slowness on Linux.
This commit is contained in:
Matt Joiner 2018-01-09 23:11:34 +11:00
parent 6239a83bd6
commit 09218898e9
2 changed files with 9 additions and 7 deletions

View File

@ -35,6 +35,7 @@ func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error) {
if err != nil { if err != nil {
return return
} }
db.NoSync = true
ret = &boltPieceCompletion{db} ret = &boltPieceCompletion{db}
return return
} }

View File

@ -3,7 +3,9 @@ package storage
import ( import (
"encoding/binary" "encoding/binary"
"path/filepath" "path/filepath"
"time"
"github.com/anacrolix/missinggo/assert"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
"github.com/anacrolix/torrent/metainfo" "github.com/anacrolix/torrent/metainfo"
@ -25,13 +27,12 @@ type boltDBTorrent struct {
} }
func NewBoltDB(filePath string) ClientImpl { func NewBoltDB(filePath string) ClientImpl {
ret := &boltDBClient{} db, err := bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, &bolt.Options{
var err error Timeout: time.Second,
ret.db, err = bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, nil) })
if err != nil { assert.Nil(err)
panic(err) db.NoSync = true
} return &boltDBClient{db}
return ret
} }
func (me *boltDBClient) Close() error { func (me *boltDBClient) Close() error {