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.
This commit is contained in:
rjl493456442 2019-09-24 10:39:45 +08:00
parent df89233b57
commit fecf6de1be

View file

@ -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,
})