You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lower allocation overhead of metrics in peer.Send #2840
In Memory profiles of full nodes, we see large amounts of heap allocation in p2p.send coming from Prometheus logging, that is ~entirely duplicate work.
We should be able to have the labels already cached (or at minimum the peer ID label cached) in the existing peer.Metrics instance.
Problem Definition
Lower heap allocation and time overhead of sending something to peers. I have no idea how much this is a dominant term in wall clock time, though I do see recv time and send time routinely in CPU profiles.
Proposal
Cache the peer ID label in p.metrics.PeerSendBytesTotal, so this is re-done on every packet send
"Another red flag is the peer-id label, which we have to investigate will not lead to a cardinality explosion as this can be the cause for degraded performance of the monitoring pipeline to the point of it being downright unusable if the values in that label exceed the 10s/100s."
Lets measure after that gets in! The memory overhead is coming from the prometheus With and Add calls I believe, so the creation of the PeerId as a string isn't the issue
Activity
cason commentedon Apr 18, 2024
There is a cache though:
cometbft/p2p/metrics.go
Line 43 in d27732a
cason commentedon Apr 18, 2024
But it doesn't apply to channel ID (which is immutable after startup) and to peer ID (this changes over time, so a cache would be good).
But in general, have per peer ID metrics looks an overkill to me.
ValarDragon commentedon Apr 18, 2024
That makes sense! I'm down for deleting per peer id metrics as well
hvanz commentedon Apr 18, 2024
I'm also in favor of deprecating this metric. I don't think it's useful for a node operator but we would need to check.
There was already a warning about the peer ID in the original PR tendermint/tendermint#2425 (review)
cason commentedon Apr 18, 2024
I am wondering why we need to cache the peer ID. It is a string, so are you sure we are creating copies here?
cason commentedon Apr 18, 2024
If the problem is only the channel's labels, #2851 should solve it.
ValarDragon commentedon Apr 18, 2024
Lets measure after that gets in! The memory overhead is coming from the prometheus
WithandAddcalls I believe, so the creation of the PeerId as a string isn't the issuecason commentedon Apr 18, 2024
Updated the PR. It is covering both send and receive side metrics.
17 remaining items
adizere commentedon Jul 4, 2024
Thanks Dev!
perf(p2p)!: Remove PeerSendBytesTotal metric (#3184)
feat(p2p)!: remove PeerReceiveBytesTotal (#3298)
perf(p2p)!: Remove PeerSendBytesTotal metric (backport #3184) (#3491)
feat(p2p)!: remove PeerReceiveBytesTotal (backport #3298) (#3492)
perf(p2p): Reduce the p2p metrics overhead. (#3411)
perf(p2p): Reduce the p2p metrics overhead. (backport #3411) (#3569)
perf(p2p): Reduce the p2p metrics overhead. (cometbft#3411)