Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: track backoff time for connected peers #445

Merged
merged 2 commits into from
Jun 29, 2023

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Jun 28, 2023

Motivation

  • To track backoff time for connected peers

Description

@twoeths twoeths requested a review from a team as a code owner June 28, 2023 09:18
src/index.ts Outdated
for (const backoff of this.backoff.values()) {
backoffSize += backoff.size
for (const [peer, expiredMs] of backoff.entries()) {
if (this.peers.has(peer)) {
metrics.connectedPeersBackoffSec.observe((expiredMs - now) / 1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset the histogram values above to have a read of current status. Similar to Lodestar's gossipsub metrics. Also record only positive numbers or histograms render poorly Math.max(0, expiredMs - now) / 1000

src/metrics.ts Outdated
connectedPeersBackoffSec: register.histogram({
name: 'gossipsub_connected_peers_backoff_seconds',
help: 'Backoff time in seconds',
buckets: [1, 2, 4, 8, 16, 32, 64, 128, 256]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Values could align more with spec parameters such that

[1,2,4,10,20,60,120]

also do add a comment like:

Using 1 seconds as minimum as that's close to the heartbeat duration, no need for more resolution.
As per spec, backoff times are 10 seconds for UnsubscribeBackoff and 60 seconds for PruneBackoff.
Higher values of 60 seconds should not occur, but we add 120 seconds just in case
https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#overview-of-new-parameters

@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: -0.13 ⚠️

Comparison is base (cbdae04) 82.51% compared to head (ff794b4) 82.39%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #445      +/-   ##
==========================================
- Coverage   82.51%   82.39%   -0.13%     
==========================================
  Files          48       48              
  Lines       11966    11984      +18     
  Branches     1279     1279              
==========================================
  Hits         9874     9874              
- Misses       2092     2110      +18     
Impacted Files Coverage Δ
src/index.ts 69.91% <0.00%> (-0.20%) ⬇️
src/metrics.ts 18.63% <0.00%> (-0.23%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wemeetagain wemeetagain merged commit 8646b4d into master Jun 29, 2023
@wemeetagain wemeetagain deleted the tuyen/backoff_time_metric branch June 29, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Track backoff times in connected peers
4 participants