From b661beceaedeae53ac75eceed089284752ea4fce Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Wed, 23 Sep 2015 11:49:00 -0700 Subject: [PATCH] Revert "limit write concurrency of leveldb to max open file handles limit" This reverts commit 8d2d380676797ef7ba68adf5416fae6f90a171f9. --- chunks/leveldb_store.go | 18 +++++------------- http/http_server.go | 11 ++++++----- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/chunks/leveldb_store.go b/chunks/leveldb_store.go index 37a8f4a26f..8fa4738c1d 100644 --- a/chunks/leveldb_store.go +++ b/chunks/leveldb_store.go @@ -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 { diff --git a/http/http_server.go b/http/http_server.go index 52a8a314bd..8701e36e67 100644 --- a/http/http_server.go +++ b/http/http_server.go @@ -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), } }