mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: bump the state node count and add metrics
This commit is contained in:
parent
c9cdf144d5
commit
a90f745a67
5 changed files with 34 additions and 9 deletions
|
|
@ -42,9 +42,8 @@ var (
|
|||
MaxBlockFetch = 128 // Amount of blocks to be fetched per retrieval request
|
||||
MaxHeaderFetch = 192 // Amount of block headers to be fetched per retrieval request
|
||||
MaxSkeletonSize = 128 // Number of header fetches to need for a skeleton assembly
|
||||
MaxBodyFetch = 128 // Amount of block bodies to be fetched per retrieval request
|
||||
MaxReceiptFetch = 256 // Amount of transaction receipts to allow fetching per request
|
||||
MaxStateFetch = 384 // Amount of node state values to allow fetching per request
|
||||
MaxStateFetch = 1024 // Amount of node state values to allow fetching per request
|
||||
|
||||
rttMinEstimate = 2 * time.Second // Minimum round-trip time to target for download requests
|
||||
rttMaxEstimate = 20 * time.Second // Maximum round-trip time to target for download requests
|
||||
|
|
|
|||
|
|
@ -39,5 +39,8 @@ var (
|
|||
receiptTimeoutMeter = metrics.NewRegisteredMeter("eth/downloader/receipts/timeout", nil)
|
||||
|
||||
stateInMeter = metrics.NewRegisteredMeter("eth/downloader/states/in", nil)
|
||||
stateReqTimer = metrics.NewRegisteredTimer("eth/download/state/req", nil)
|
||||
stateDropMeter = metrics.NewRegisteredMeter("eth/downloader/states/drop", nil)
|
||||
stateNodeSizeMeter = metrics.NewRegisteredMeter("eth/download/state/nodesize", nil)
|
||||
stateRespSizeMeter = metrics.NewRegisteredMeter("eth/download/state/size", nil)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/trie"
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
|
@ -41,6 +42,7 @@ type stateReq struct {
|
|||
peer *peerConnection // Peer that we're requesting from
|
||||
response [][]byte // Response data of the peer (nil for timeouts)
|
||||
dropped bool // Flag whether the peer dropped off early
|
||||
sendAt time.Time // Time when the request was made
|
||||
}
|
||||
|
||||
// timedOut returns if this request timed out.
|
||||
|
|
@ -336,6 +338,10 @@ func (s *stateSync) loop() (err error) {
|
|||
return err
|
||||
}
|
||||
req.peer.SetNodeDataIdle(delivered)
|
||||
// Trace average rtt of state request
|
||||
if metrics.EnabledExpensive {
|
||||
stateReqTimer.UpdateSince(req.sendAt)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -375,6 +381,7 @@ func (s *stateSync) assignTasks() {
|
|||
req.peer.log.Trace("Requesting new batch of data", "type", "state", "count", len(req.items))
|
||||
select {
|
||||
case s.d.trackStateReq <- req:
|
||||
req.sendAt = time.Now()
|
||||
req.peer.FetchNodeData(req.items)
|
||||
case <-s.cancel:
|
||||
case <-s.d.cancelCh:
|
||||
|
|
@ -428,6 +435,7 @@ func (s *stateSync) process(req *stateReq) (int, error) {
|
|||
}(time.Now())
|
||||
|
||||
// Iterate over all the delivered data and inject one-by-one into the trie
|
||||
size := 0
|
||||
for _, blob := range req.response {
|
||||
_, hash, err := s.processNodeData(blob)
|
||||
switch err {
|
||||
|
|
@ -443,6 +451,12 @@ func (s *stateSync) process(req *stateReq) (int, error) {
|
|||
return successful, fmt.Errorf("invalid state node %s: %v", hash.TerminalString(), err)
|
||||
}
|
||||
delete(req.tasks, hash)
|
||||
size += len(blob)
|
||||
}
|
||||
// Trace the average node size and total response size we receive
|
||||
if metrics.EnabledExpensive && len(req.response) > 0 {
|
||||
stateNodeSizeMeter.Mark(int64(size / len(req.response)))
|
||||
stateRespSizeMeter.Mark(int64(size))
|
||||
}
|
||||
// Put unfulfilled tasks back into the retry queue
|
||||
npeers := s.d.peers.Len()
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/metrics"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
|
|
@ -584,6 +585,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
|||
hash common.Hash
|
||||
bytes int
|
||||
data [][]byte
|
||||
start = time.Now()
|
||||
count int
|
||||
)
|
||||
for bytes < softResponseLimit && len(data) < downloader.MaxStateFetch {
|
||||
// Retrieve the hash of the next state entry
|
||||
|
|
@ -597,6 +600,11 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
|||
data = append(data, entry)
|
||||
bytes += len(entry)
|
||||
}
|
||||
count += 1
|
||||
}
|
||||
// Trace the time cost for looking for a trie node in database.
|
||||
if count > 0 && metrics.EnabledExpensive {
|
||||
reqStateLookupTimer.Update(time.Duration(time.Since(start)) / time.Duration(count))
|
||||
}
|
||||
return p.SendNodeData(data)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ var (
|
|||
reqStateInTrafficMeter = metrics.NewRegisteredMeter("eth/req/states/in/traffic", nil)
|
||||
reqStateOutPacketsMeter = metrics.NewRegisteredMeter("eth/req/states/out/packets", nil)
|
||||
reqStateOutTrafficMeter = metrics.NewRegisteredMeter("eth/req/states/out/traffic", nil)
|
||||
reqStateLookupTimer = metrics.NewRegisteredTimer("eth/req/states/out/lookup", nil)
|
||||
reqReceiptInPacketsMeter = metrics.NewRegisteredMeter("eth/req/receipts/in/packets", nil)
|
||||
reqReceiptInTrafficMeter = metrics.NewRegisteredMeter("eth/req/receipts/in/traffic", nil)
|
||||
reqReceiptOutPacketsMeter = metrics.NewRegisteredMeter("eth/req/receipts/out/packets", nil)
|
||||
|
|
|
|||
Loading…
Reference in a new issue