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

Optimize GossipScore IP colocation calculation #248

Merged

Conversation

Nashatyrev
Copy link
Collaborator

@Nashatyrev Nashatyrev commented Jul 14, 2022

The current algorithm of IP colocation score calculation has O(n^2) complexity and consumes significant CPU with lots of peer connections

This PR:

  • Modifies the algorithm to O(n) complexity
  • Extracts the PeerIP class (which could be adjusted to IPv6 and colocation criteria later)
  • Pass more specific Multiaddr type for the onConnected() event

@Nashatyrev Nashatyrev force-pushed the optimization/gossip-score-ip-colocation branch from dfb72c3 to eb6b1e4 Compare July 18, 2022 09:00
…p-score-ip-colocation

# Conflicts:
#	src/main/kotlin/io/libp2p/pubsub/gossip/GossipRouter.kt
@Nashatyrev Nashatyrev marked this pull request as ready for review July 18, 2022 17:09
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM.

@Nashatyrev Nashatyrev merged commit d3d7ed3 into libp2p:develop Jul 19, 2022
@Nashatyrev Nashatyrev changed the title Optimizate GossipScore IP colocation calculation Optimize GossipScore IP colocation calculation Jul 19, 2022
@Nashatyrev Nashatyrev deleted the optimization/gossip-score-ip-colocation branch July 19, 2022 14:14
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.

2 participants