Skip to content

Comments

bitswap/client: broadcast reduction and metrics#937

Merged
gammazero merged 35 commits intomainfrom
broadcast-metrics
Jun 16, 2025
Merged

bitswap/client: broadcast reduction and metrics#937
gammazero merged 35 commits intomainfrom
broadcast-metrics

Conversation

@gammazero
Copy link
Contributor

@gammazero gammazero commented May 29, 2025

New Metrics

  • ipfs_bitswap_wanthaves_broadcast: Count of want-haves set as broadcasts
  • ipfs_bitswap_haves_received: Count of total have responses
  • ipfs_bitswap_bcast_skips_total{: Count of broadcasts skipped as part of spam reduction logic
  • ipfs_bitswap_unique_blocks_received: Count of non-duplicate blocks recieved.

Broadcast reduction logic

Send broadcast if:

  • Peer has previously sent blocks or have-blocks
  • Optionally, Peer is on local network or configured for peering
  • Optionally, Peer has pending message
  • Optionally send broadcasts to 1 or more peers that are not broadcast targets by above rules.

Otherwise send broadcast to peer.

References

@gammazero gammazero marked this pull request as ready for review June 5, 2025 01:43
@gammazero gammazero requested a review from a team as a code owner June 5, 2025 01:43
@gammazero gammazero changed the title Bitswap spam reduction and metrics bitswap/client: broadcast reduction and metrics Jun 5, 2025
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Leaving internals review to @aschmahmann,
but we need to document all these new knobs better (port docs from kubo pr?)

Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

A few nits:

@gammazero gammazero requested a review from lidel June 12, 2025 08:17
Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

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

Some small nits and a couple of questions from my side

@hsanjuan
Copy link
Contributor

One more comment as I gave some thought: I think it would be good to think if we should broadcast to protected/tagged connections. Tagging a connection is a way of specifying that different peer is your friend. I don't know if we can distinguish between manual user tags and temporary tags made by bitswap/dht though...

@hsanjuan
Copy link
Contributor

@hsanjuan @lidel Should broadcasting to peering peers be separately configurable from broadcasting to local peers?

I think yes.

  1. If local peer and broadcastToLocal == true -> broadcast
  2. If tagged peer and broadcastToTagged == true -> broadcast

- Rename broadcast control options
- Configure applying control to local and peered peers separately
- Rename broadcastConfig to broadcastControl
Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

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

LGTM

@gammazero gammazero merged commit 1d75ffd into main Jun 16, 2025
14 checks passed
@gammazero gammazero deleted the broadcast-metrics branch September 10, 2025 00:06
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.

5 participants