mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
eth/downloader: simplify throttle threshold logic. increase downloader block cache memory to 1gb.
This commit is contained in:
parent
bfeffc573c
commit
3782d2ac67
2 changed files with 6 additions and 16 deletions
|
|
@ -43,9 +43,8 @@ const (
|
|||
|
||||
var (
|
||||
blockCacheMaxItems = 8192 // Maximum number of blocks to cache before throttling the download
|
||||
blockCacheInitialItems = 2048 // Initial number of blocks to start fetching, before we know the sizes of the blocks
|
||||
blockCacheMemory = 256 * 1024 * 1024 // Maximum amount of memory to use for block caching
|
||||
blockCacheSizeWeight = 0.1 // Multiplier to approximate the average block size based on past ones
|
||||
blockCacheInitialItems = 16 // Initial number of blocks to start fetching, before we know the sizes of the blocks
|
||||
blockCacheMemory = 1024 * 1024 * 1024 // Maximum amount of memory to use for block caching
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -377,12 +376,8 @@ func (q *queue) Results(block bool) []*fetchResult {
|
|||
results := q.resultCache.GetCompleted(maxResultsProcess)
|
||||
|
||||
// set a throttle threshhold based on estimated worst-sized block that can be created for a given gas limit.
|
||||
targetSize := uint64(256_000_000)
|
||||
gasLimit := results[0].Header.GasLimit
|
||||
if gasLimit == 0 {
|
||||
gasLimit = 1
|
||||
}
|
||||
throttleThreshold := min(targetSize/(gasLimit/10), 2048)
|
||||
gasLimit := max(results[0].Header.GasLimit, 1)
|
||||
throttleThreshold := min(uint64(blockCacheMemory)/(gasLimit/10), 2048)
|
||||
throttleThreshold = q.resultCache.SetThrottleThreshold(throttleThreshold)
|
||||
|
||||
// With results removed from the cache, wake throttled fetchers
|
||||
|
|
|
|||
|
|
@ -60,12 +60,7 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 {
|
|||
defer r.lock.Unlock()
|
||||
|
||||
fmt.Printf("set throttle threshold: %d\n", threshold)
|
||||
|
||||
limit := uint64(len(r.items))
|
||||
if threshold >= limit {
|
||||
threshold = limit
|
||||
}
|
||||
r.throttleThreshold = threshold
|
||||
r.throttleThreshold = min(uint64(len(r.items)), threshold)
|
||||
return r.throttleThreshold
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue