mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +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 (
|
var (
|
||||||
blockCacheMaxItems = 8192 // Maximum number of blocks to cache before throttling the download
|
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
|
blockCacheInitialItems = 16 // 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
|
blockCacheMemory = 1024 * 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
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -377,12 +376,8 @@ func (q *queue) Results(block bool) []*fetchResult {
|
||||||
results := q.resultCache.GetCompleted(maxResultsProcess)
|
results := q.resultCache.GetCompleted(maxResultsProcess)
|
||||||
|
|
||||||
// set a throttle threshhold based on estimated worst-sized block that can be created for a given gas limit.
|
// 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 := max(results[0].Header.GasLimit, 1)
|
||||||
gasLimit := results[0].Header.GasLimit
|
throttleThreshold := min(uint64(blockCacheMemory)/(gasLimit/10), 2048)
|
||||||
if gasLimit == 0 {
|
|
||||||
gasLimit = 1
|
|
||||||
}
|
|
||||||
throttleThreshold := min(targetSize/(gasLimit/10), 2048)
|
|
||||||
throttleThreshold = q.resultCache.SetThrottleThreshold(throttleThreshold)
|
throttleThreshold = q.resultCache.SetThrottleThreshold(throttleThreshold)
|
||||||
|
|
||||||
// With results removed from the cache, wake throttled fetchers
|
// With results removed from the cache, wake throttled fetchers
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,7 @@ func (r *resultStore) SetThrottleThreshold(threshold uint64) uint64 {
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
|
||||||
fmt.Printf("set throttle threshold: %d\n", threshold)
|
fmt.Printf("set throttle threshold: %d\n", threshold)
|
||||||
|
r.throttleThreshold = min(uint64(len(r.items)), threshold)
|
||||||
limit := uint64(len(r.items))
|
|
||||||
if threshold >= limit {
|
|
||||||
threshold = limit
|
|
||||||
}
|
|
||||||
r.throttleThreshold = threshold
|
|
||||||
return r.throttleThreshold
|
return r.throttleThreshold
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue