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

fix: decrease default routing table size #3023

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Mar 3, 2025

Reduces the default routing table size to 1280 (down from 5120).

This improves CPU/memory/network usage as we don't need to sort as many peers when finding the closest ones to a given key, nor do we need to contact as many to ensure only live peers are still in the table.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Reduces the default routing table size to 1280.

This improves CPU/memory/network usage as we don't need to sort as
many peers when finding the closest ones to a given key, nor do we
need to contact as many to ensure only live peers are still in the
table.
@achingbrain achingbrain requested a review from a team as a code owner March 3, 2025 12:20
@2color
Copy link
Contributor

2color commented Mar 3, 2025

How does this compare to the defaults in https://github.com/libp2p/go-libp2p-kad-dht?

@achingbrain
Copy link
Member Author

How does this compare to the defaults in libp2p/go-libp2p-kad-dht?

go-libp2p-kad-dht uses a different data structure for it's routing table, something more similar to #2747 so a direct comparison is difficult.

Instead js-libp2p has a binary trie with peers equally distributed across the address space - the idea is this results in faster lookups for arbitrary data since we know of more peers further from our own peer id. To ensure we stay well connected it also maintains a separate list of the 20 peers closest to the node's peer ID so far encountered.

@achingbrain achingbrain merged commit 48cd9b6 into main Mar 3, 2025
33 checks passed
@achingbrain achingbrain deleted the fix/decrease-default-routing-table-size branch March 3, 2025 18:10
@achingbrain achingbrain mentioned this pull request Mar 3, 2025
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