mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
eth/downloader: bump block cache target from 256 mb to 2 gb. increase max in-flight block body requests from 8192 to 32768. add a metric for count of in-flight block body retrievals.
This commit is contained in:
parent
1591d165c4
commit
aa65601146
3 changed files with 35 additions and 4 deletions
|
|
@ -32,6 +32,9 @@ var (
|
||||||
bodyDropMeter = metrics.NewRegisteredMeter("eth/downloader/bodies/drop", nil)
|
bodyDropMeter = metrics.NewRegisteredMeter("eth/downloader/bodies/drop", nil)
|
||||||
bodyTimeoutMeter = metrics.NewRegisteredMeter("eth/downloader/bodies/timeout", nil)
|
bodyTimeoutMeter = metrics.NewRegisteredMeter("eth/downloader/bodies/timeout", nil)
|
||||||
|
|
||||||
|
blockSizeGauge = metrics.NewRegisteredGauge("eth/downloader/blocks/size", nil)
|
||||||
|
pendingBodyGauge = metrics.NewRegisteredGauge("eth/downloader/bodies/pending", nil)
|
||||||
|
|
||||||
receiptInMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/in", nil)
|
receiptInMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/in", nil)
|
||||||
receiptReqTimer = metrics.NewRegisteredTimer("eth/downloader/receipts/req", nil)
|
receiptReqTimer = metrics.NewRegisteredTimer("eth/downloader/receipts/req", nil)
|
||||||
receiptDropMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/drop", nil)
|
receiptDropMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/drop", nil)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/prque"
|
"github.com/ethereum/go-ethereum/common/prque"
|
||||||
|
|
@ -42,10 +43,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
blockCacheMaxItems = 8192 // Maximum number of blocks to cache before throttling the download
|
blockCacheMaxItems = 8192 * 4 // 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 = 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
|
blockCacheMemory = 2 * 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
|
blockCacheSizeWeight = 0.1 // Multiplier to approximate the average block size based on past ones
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -88,6 +89,18 @@ func newFetchResult(header *types.Header, snapSync bool) *fetchResult {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *fetchResult) Size() int {
|
||||||
|
receiptsSize := 0
|
||||||
|
for _, r := range f.Receipts {
|
||||||
|
receiptsSize += int(r.Size())
|
||||||
|
}
|
||||||
|
txsSize := 0
|
||||||
|
for _, t := range f.Transactions {
|
||||||
|
txsSize += int(t.Size())
|
||||||
|
}
|
||||||
|
return common.HashLength*len(f.Uncles) + int(unsafe.Sizeof(types.Withdrawal{})) + int(f.Header.Size()) + receiptsSize + txsSize
|
||||||
|
}
|
||||||
|
|
||||||
// body returns a representation of the fetch result as a types.Body object.
|
// body returns a representation of the fetch result as a types.Body object.
|
||||||
func (f *fetchResult) body() types.Body {
|
func (f *fetchResult) body() types.Body {
|
||||||
return types.Body{
|
return types.Body{
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ type resultStore struct {
|
||||||
throttleThreshold uint64
|
throttleThreshold uint64
|
||||||
|
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
|
|
||||||
|
pendingCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newResultStore(size int) *resultStore {
|
func newResultStore(size int) *resultStore {
|
||||||
|
|
@ -88,6 +90,7 @@ func (r *resultStore) AddFetch(header *types.Header, snapSync bool) (stale, thro
|
||||||
if item == nil {
|
if item == nil {
|
||||||
item = newFetchResult(header, snapSync)
|
item = newFetchResult(header, snapSync)
|
||||||
r.items[index] = item
|
r.items[index] = item
|
||||||
|
r.pendingCount++
|
||||||
}
|
}
|
||||||
return stale, throttled, item, err
|
return stale, throttled, item, err
|
||||||
}
|
}
|
||||||
|
|
@ -169,6 +172,18 @@ func (r *resultStore) GetCompleted(limit int) []*fetchResult {
|
||||||
if limit > completed {
|
if limit > completed {
|
||||||
limit = completed
|
limit = completed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var totalSize int
|
||||||
|
for i := 0; i < limit; i++ {
|
||||||
|
totalSize += r.items[i].Size()
|
||||||
|
}
|
||||||
|
if limit > 0 {
|
||||||
|
blockSizeGauge.Update(int64(totalSize / limit))
|
||||||
|
r.pendingCount -= limit
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingBodyGauge.Update(int64(r.pendingCount))
|
||||||
|
|
||||||
results := make([]*fetchResult, limit)
|
results := make([]*fetchResult, limit)
|
||||||
copy(results, r.items[:limit])
|
copy(results, r.items[:limit])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue