From fecf6de1be5f59e1baef3be5bdc7beb73c5d16eb Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Tue, 24 Sep 2019 10:39:45 +0800 Subject: [PATCH] ethdb/leveldb: change leveldb config There are two options changed. Now BlockCacheCapacity is assigned with a larger value(1/2 total memory cache allowance), while at the same time WriteBuffer is reduced to default value 4MB. The reason for this change is: (1) The larger blockCache, the more data block, index block and filter block can be cached. For ethereum case read, we have very high chance to traverse the whole levels. So we can reduce the overhead of reading "meta data". (2) WriteBuffer value equals to the file size of level0. So if we accumulate too muh data in WriteBuffer, it will dump the whole buffer to disk at some time. So the pressure of compaction is increased suddenly. The disk read and write will have spike. --- ethdb/leveldb/leveldb.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ethdb/leveldb/leveldb.go b/ethdb/leveldb/leveldb.go index 378d4c3cd2..71ad8cd227 100644 --- a/ethdb/leveldb/leveldb.go +++ b/ethdb/leveldb/leveldb.go @@ -97,8 +97,11 @@ func New(file string, cache int, handles int, namespace string) (*Database, erro // Open the db and recover any potential corruptions db, err := leveldb.OpenFile(file, &opt.Options{ OpenFilesCacheCapacity: handles, - BlockCacheCapacity: cache / 2 * opt.MiB, - WriteBuffer: cache / 4 * opt.MiB, // Two of these are used internally + + // BlockCache can be used for caching: data block, index block as well as + // filter block. The more capacity block cache has, the less disk hit we + // have. + BlockCacheCapacity: cache * opt.MiB, Filter: filter.NewBloomFilter(10), DisableSeeksCompaction: true, })