mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
set different cache size
Signed-off-by: Delweng <delweng@gmail.com>
This commit is contained in:
parent
fcb657fff4
commit
2bb24fa3fa
2 changed files with 10 additions and 6 deletions
|
|
@ -61,8 +61,12 @@ var (
|
||||||
// maxDiffLayers is the maximum diff layers allowed in the layer tree.
|
// maxDiffLayers is the maximum diff layers allowed in the layer tree.
|
||||||
maxDiffLayers = 128
|
maxDiffLayers = 128
|
||||||
|
|
||||||
// historyCacheSize is the maximum size of history cache.
|
// historyIndexCacheSize is the maximum count of history index cache.
|
||||||
historyCacheSize = 4096
|
// Each indexBlockDesc is 14bytes, assume each account has 10 descriptors,
|
||||||
|
// then the total memory usage is ~54MB.
|
||||||
|
historyIndexCacheSize = 409600
|
||||||
|
// historyBlockCacheSize is the maximum count of history block cache.
|
||||||
|
historyBlockCacheSize = 4096
|
||||||
)
|
)
|
||||||
|
|
||||||
// layer is the interface implemented by all state layers which includes some
|
// layer is the interface implemented by all state layers which includes some
|
||||||
|
|
@ -246,7 +250,7 @@ func New(diskdb ethdb.Database, config *Config, isVerkle bool) *Database {
|
||||||
config: config,
|
config: config,
|
||||||
diskdb: diskdb,
|
diskdb: diskdb,
|
||||||
hasher: merkleNodeHasher,
|
hasher: merkleNodeHasher,
|
||||||
cacher: newHistoryCacher(historyCacheSize),
|
cacher: newHistoryCacher(historyIndexCacheSize, historyBlockCacheSize),
|
||||||
}
|
}
|
||||||
// Establish a dedicated database namespace tailored for verkle-specific
|
// Establish a dedicated database namespace tailored for verkle-specific
|
||||||
// data, ensuring the isolation of both verkle and merkle tree data. It's
|
// data, ensuring the isolation of both verkle and merkle tree data. It's
|
||||||
|
|
|
||||||
|
|
@ -198,10 +198,10 @@ type historyCacher struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHistoryCacher creates a new historyCacher instance.
|
// newHistoryCacher creates a new historyCacher instance.
|
||||||
func newHistoryCacher(size int) *historyCacher {
|
func newHistoryCacher(indexSize, blockSize int) *historyCacher {
|
||||||
return &historyCacher{
|
return &historyCacher{
|
||||||
index: lru.NewCache[string, []byte](size),
|
index: lru.NewCache[string, []byte](indexSize),
|
||||||
block: lru.NewCache[string, []byte](size),
|
block: lru.NewCache[string, []byte](blockSize),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue