Skip to content

Commit b4fecd5

Browse files
authored
telemetry: Count and report the number of duplicate proposals and MsgDigestSkipTag messages received (#4605)
1 parent d389196 commit b4fecd5

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

agreement/proposalStore.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ package agreement
1818

1919
import (
2020
"fmt"
21+
22+
"github.com/algorand/go-algorand/util/metrics"
2123
)
2224

25+
var proposalAlreadyFilledCounter = metrics.MakeCounter(
26+
metrics.MetricName{Name: "algod_agreement_proposal_already_filled", Description: "Number of times a duplicate proposal payload was received before validation"})
27+
28+
var proposalAlreadyAssembledCounter = metrics.MakeCounter(
29+
metrics.MetricName{Name: "algod_agreement_proposal_already_assembled", Description: "Number of times a duplicate proposal payload was received after validation"})
30+
2331
// An blockAssembler contains the proposal data associated with some
2432
// proposal-value.
2533
//
@@ -52,10 +60,12 @@ type blockAssembler struct {
5260
// an error if the pipelining operation is redundant.
5361
func (a blockAssembler) pipeline(p unauthenticatedProposal) (blockAssembler, error) {
5462
if a.Assembled {
63+
proposalAlreadyAssembledCounter.Inc(nil)
5564
return a, fmt.Errorf("blockAssembler.pipeline: already assembled")
5665
}
5766

5867
if a.Filled {
68+
proposalAlreadyFilledCounter.Inc(nil)
5969
return a, fmt.Errorf("blockAssembler.pipeline: already filled")
6070
}
6171

logging/telemetryspec/event.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ type PeerConnectionDetails struct {
300300
Endpoint string `json:",omitempty"`
301301
// MessageDelay is the avarage relative message delay. Not being used for incoming connection.
302302
MessageDelay int64 `json:",omitempty"`
303+
// DuplicateFilterCount is the number of times this peer has sent us a message hash to filter that it had already sent before.
304+
DuplicateFilterCount int64
303305
}
304306

305307
// CatchpointGenerationEvent event

network/wsNetwork.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,9 +1749,10 @@ func (wn *WebsocketNetwork) sendPeerConnectionsTelemetryStatus() {
17491749
var connectionDetails telemetryspec.PeersConnectionDetails
17501750
for _, peer := range peers {
17511751
connDetail := telemetryspec.PeerConnectionDetails{
1752-
ConnectionDuration: uint(now.Sub(peer.createTime).Seconds()),
1753-
TelemetryGUID: peer.TelemetryGUID,
1754-
InstanceName: peer.InstanceName,
1752+
ConnectionDuration: uint(now.Sub(peer.createTime).Seconds()),
1753+
TelemetryGUID: peer.TelemetryGUID,
1754+
InstanceName: peer.InstanceName,
1755+
DuplicateFilterCount: peer.duplicateFilterCount,
17551756
}
17561757
if peer.outgoing {
17571758
connDetail.Address = justHost(peer.conn.RemoteAddr().String())

network/wsPeer.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ var networkMessageQueueMicrosTotal = metrics.MakeCounter(metrics.MetricName{Name
7575

7676
var duplicateNetworkMessageReceivedTotal = metrics.MakeCounter(metrics.DuplicateNetworkMessageReceivedTotal)
7777
var duplicateNetworkMessageReceivedBytesTotal = metrics.MakeCounter(metrics.DuplicateNetworkMessageReceivedBytesTotal)
78+
var duplicateNetworkFilterReceivedTotal = metrics.MakeCounter(metrics.DuplicateNetworkFilterReceivedTotal)
7879
var outgoingNetworkMessageFilteredOutTotal = metrics.MakeCounter(metrics.OutgoingNetworkMessageFilteredOutTotal)
7980
var outgoingNetworkMessageFilteredOutBytesTotal = metrics.MakeCounter(metrics.OutgoingNetworkMessageFilteredOutBytesTotal)
8081

@@ -184,6 +185,9 @@ type wsPeer struct {
184185

185186
incomingMsgFilter *messageFilter
186187
outgoingMsgFilter *messageFilter
188+
// duplicateFilterCount counts how many times the remote peer has sent us a message hash
189+
// to filter that it had already sent before.
190+
duplicateFilterCount int64
187191

188192
processed chan struct{}
189193

@@ -576,7 +580,14 @@ func (wp *wsPeer) handleFilterMessage(msg IncomingMessage) {
576580
var digest crypto.Digest
577581
copy(digest[:], msg.Data)
578582
//wp.net.log.Debugf("add filter %v", digest)
579-
wp.outgoingMsgFilter.CheckDigest(digest, true, true)
583+
has := wp.outgoingMsgFilter.CheckDigest(digest, true, true)
584+
if has {
585+
// Count that this peer has sent us duplicate filter messages: this means it received the same
586+
// large message concurrently from several peers, and then sent the filter message to us after
587+
// each large message finished transferring.
588+
duplicateNetworkFilterReceivedTotal.Inc(nil)
589+
atomic.AddInt64(&wp.duplicateFilterCount, 1)
590+
}
580591
}
581592

582593
func (wp *wsPeer) writeLoopSend(msgs sendMessages) disconnectReason {

util/metrics/metrics.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ var (
4949
DuplicateNetworkMessageReceivedTotal = MetricName{Name: "algod_network_duplicate_message_received_total", Description: "Total number of duplicate messages that were received from the network"}
5050
// DuplicateNetworkMessageReceivedBytesTotal The total number ,in bytes, of the duplicate messages that were received from the network
5151
DuplicateNetworkMessageReceivedBytesTotal = MetricName{Name: "algod_network_duplicate_message_received_bytes_total", Description: "The total number ,in bytes, of the duplicate messages that were received from the network"}
52+
// DuplicateNetworkFilterReceivedTotal Total number of duplicate filter messages (tag MsgDigestSkipTag) that were received from the network
53+
DuplicateNetworkFilterReceivedTotal = MetricName{Name: "algod_network_duplicate_filter_received_total", Description: "Total number of duplicate filter messages that were received from the network"}
5254
// OutgoingNetworkMessageFilteredOutTotal Total number of messages that were not sent per peer request
5355
OutgoingNetworkMessageFilteredOutTotal = MetricName{Name: "algod_outgoing_network_message_filtered_out_total", Description: "Total number of messages that were not sent per peer request"}
5456
// OutgoingNetworkMessageFilteredOutBytesTotal Total number of bytes saved by not sending messages that were asked not to be sent by peer

0 commit comments

Comments
 (0)