WIP: Feature/6/jeffreypicard/dockerize for deployment #7

Closed
jeffreypicard wants to merge 80 commits from feature/6/jeffreypicard/dockerize-for-deployment into master
3 changed files with 11 additions and 14 deletions
Showing only changes of commit 188023b729 - Show all commits

View file

@ -37,7 +37,7 @@ const (
// maxOpenFiles is the max number of open files to maintain in the // maxOpenFiles is the max number of open files to maintain in the
// open blocks cache. Note that this does not include the current // open blocks cache. Note that this does not include the current
// write file, so there will typically be one more than this value open. // write file, so there will typically be one more than this value open.
maxOpenFiles = 25 maxOpenFiles = 40
// maxBlockFileSize is the maximum size for each file used to store // maxBlockFileSize is the maximum size for each file used to store
// blocks. // blocks.

View file

@ -2001,10 +2001,11 @@ func openDB(dbPath string, network wire.BitcoinNet, create bool) (database.DB, e
// Open the metadata database (will create it if needed). // Open the metadata database (will create it if needed).
opts := opt.Options{ opts := opt.Options{
ErrorIfExist: create, ErrorIfExist: create,
Strict: opt.DefaultStrict, Strict: opt.DefaultStrict,
Compression: opt.NoCompression, Compression: opt.NoCompression,
Filter: filter.NewBloomFilter(10), Filter: filter.NewBloomFilter(10),
OpenFilesCacheCapacity: 2000,
} }
ldb, err := leveldb.OpenFile(metadataDbPath, &opts) ldb, err := leveldb.OpenFile(metadataDbPath, &opts)
if err != nil { if err != nil {

View file

@ -23,7 +23,7 @@ const (
// defaultFlushSecs is the default number of seconds to use as a // defaultFlushSecs is the default number of seconds to use as a
// threshold in between database cache flushes when the cache size has // threshold in between database cache flushes when the cache size has
// not been exceeded. // not been exceeded.
defaultFlushSecs = 300 // 5 minutes defaultFlushSecs = 120 // 2 minutes
// ldbBatchHeaderSize is the size of a leveldb batch header which // ldbBatchHeaderSize is the size of a leveldb batch header which
// includes the sequence header and record counter. // includes the sequence header and record counter.
@ -499,10 +499,12 @@ func (c *dbCache) flush() error {
// Since the cached keys to be added and removed use an immutable treap, // Since the cached keys to be added and removed use an immutable treap,
// a snapshot is simply obtaining the root of the tree under the lock // a snapshot is simply obtaining the root of the tree under the lock
// which is used to atomically swap the root. // which is used to atomically swap the root.
c.cacheLock.RLock() c.cacheLock.Lock()
cachedKeys := c.cachedKeys cachedKeys := c.cachedKeys
cachedRemove := c.cachedRemove cachedRemove := c.cachedRemove
c.cacheLock.RUnlock() c.cachedKeys = treap.NewImmutable()
c.cachedRemove = treap.NewImmutable()
c.cacheLock.Unlock()
// Nothing to do if there is no data to flush. // Nothing to do if there is no data to flush.
if cachedKeys.Len() == 0 && cachedRemove.Len() == 0 { if cachedKeys.Len() == 0 && cachedRemove.Len() == 0 {
@ -514,12 +516,6 @@ func (c *dbCache) flush() error {
return err return err
} }
// Clear the cache since it has been flushed.
c.cacheLock.Lock()
c.cachedKeys = treap.NewImmutable()
c.cachedRemove = treap.NewImmutable()
c.cacheLock.Unlock()
return nil return nil
} }