Revert "limit write concurrency of leveldb to max open file handles limit"

This reverts commit 8d2d380676.
This commit is contained in:
Rafael Weinstein
2015-09-23 11:49:00 -07:00
parent 915f9013e9
commit b661beceae
2 changed files with 11 additions and 18 deletions

View File

@@ -22,10 +22,9 @@ func toChunkKey(r ref.Ref) []byte {
}
type LevelDBStore struct {
db *leveldb.DB
mu *sync.Mutex
putCount int // for testing
concurrentWriteLimit chan struct{}
db *leveldb.DB
mu *sync.Mutex
putCount int // for testing
}
func NewLevelDBStore(dir string, maxFileHandles int) *LevelDBStore {
@@ -35,15 +34,10 @@ func NewLevelDBStore(dir string, maxFileHandles int) *LevelDBStore {
Compression: opt.NoCompression,
Filter: filter.NewBloomFilter(10), // 10 bits/key
OpenFilesCacheCapacity: maxFileHandles,
WriteBuffer: 1 << 24, // 16MiB,
WriteBuffer: 1 << 24, // 16MiB
})
d.Chk.NoError(err)
return &LevelDBStore{
db,
&sync.Mutex{},
0,
make(chan struct{}, maxFileHandles),
}
return &LevelDBStore{db, &sync.Mutex{}, 0}
}
func (l *LevelDBStore) Root() ref.Ref {
@@ -92,11 +86,9 @@ func (l *LevelDBStore) Put(c Chunk) {
return
}
l.concurrentWriteLimit <- struct{}{}
err := l.db.Put(toChunkKey(c.Ref()), c.Data(), nil)
d.Chk.NoError(err)
l.putCount += 1
<-l.concurrentWriteLimit
}
func (l *LevelDBStore) Close() error {

View File

@@ -23,15 +23,16 @@ const (
)
type httpServer struct {
cs chunks.ChunkStore
port int
l *net.Listener
conns map[net.Conn]http.ConnState
cs chunks.ChunkStore
port int
l *net.Listener
conns map[net.Conn]http.ConnState
writeLimit chan struct{}
}
func NewHttpServer(cs chunks.ChunkStore, port int) *httpServer {
return &httpServer{
cs, port, nil, map[net.Conn]http.ConnState{},
cs, port, nil, map[net.Conn]http.ConnState{}, make(chan struct{}, maxConcurrentPuts),
}
}