Skip to content

Conversation

@stormshield-frb
Copy link
Contributor

Description

Our average peer has over 10 advertised addresses. Doing so, identify was continuously (every 1 minute) emitting ToSwarm::NewExternalAddrOfPeer which was overflowing our logs and was making the PeerCache kind of useless.

For this reason, we made some changes in order to be able to configure the number of addresses that should be cached for a peer. We are upstreaming this changes.

Notes & open questions

N/A

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@stormshield-frb stormshield-frb force-pushed the feat/identify-make-peer-cache-configurable branch 3 times, most recently from 8fbd19b to be31d42 Compare August 28, 2024 15:22
@stormshield-frb stormshield-frb force-pushed the feat/identify-make-peer-cache-configurable branch from be31d42 to e5435fc Compare August 28, 2024 15:36
Copy link
Member

@dariusc93 dariusc93 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Left a couple of comments

@mergify
Copy link
Contributor

mergify bot commented Sep 5, 2024

This pull request has merge conflicts. Could you please resolve them @stormshield-frb? 🙏

@stormshield-frb stormshield-frb force-pushed the feat/identify-make-peer-cache-configurable branch from 14c1974 to 4d17c21 Compare September 6, 2024 07:57
@stormshield-frb stormshield-frb force-pushed the feat/identify-make-peer-cache-configurable branch from 1b14122 to 457c063 Compare September 6, 2024 08:04
@mergify
Copy link
Contributor

mergify bot commented Sep 26, 2024

This pull request has merge conflicts. Could you please resolve them @stormshield-frb? 🙏

Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Hi François, thanks for this! And sorry for the delay, left some comments

@mergify
Copy link
Contributor

mergify bot commented Nov 6, 2024

This pull request has merge conflicts. Could you please resolve them @stormshield-frb? 🙏

Copy link
Member

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

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

Comment on lines +57 to +60
/// For each peer, we will at most store `config.number_of_addresses_per_peer` addresses.
pub fn new(config: PeerAddressesConfig) -> Self {
let inner = LruCache::new(config.number_of_peers.get());
Self { config, inner }
Copy link
Member

@elenaf9 elenaf9 Oct 21, 2025

Choose a reason for hiding this comment

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

Ah sorry, I just noticed now that this is a breaking change.
Breaking changes in the swarm are quite painful, because we need to do a minor bump and release for every single behavior protocol that depends on the swarm.

We could avoid the breaking change by not adding the PeerAddressesConfig here and instead just add with_number_of_addresses_per_peer directly for PeerAddresses.
The PeerAddressesConfig could still live as CacheConfig in identity.

Wdyt? I understand that by now you might not be working on this anymore, so I can also push this change if folks agree with it. cc @jxs

Copy link
Member

Choose a reason for hiding this comment

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

Hi Elena, yeah agree, let's have this as a separate method.
Btw François has left Stormshield and so this account is probably not working, nonetheless I think this is a useful feature to have, I can finish this PR if you are busy

Comment on lines +57 to +60
/// For each peer, we will at most store `config.number_of_addresses_per_peer` addresses.
pub fn new(config: PeerAddressesConfig) -> Self {
let inner = LruCache::new(config.number_of_peers.get());
Self { config, inner }
Copy link
Member

Choose a reason for hiding this comment

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

Hi Elena, yeah agree, let's have this as a separate method.
Btw François has left Stormshield and so this account is probably not working, nonetheless I think this is a useful feature to have, I can finish this PR if you are busy

/// Defaults to 100
cache_size: usize,
/// Configuration for the LRU cache of discovered peers.
cache_config: Option<PeerAddressesConfig>,
Copy link
Member

Choose a reason for hiding this comment

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

is this required to be optional?

Copy link
Member

Choose a reason for hiding this comment

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

If it's None the cache is disabled. Before, cache size 0 was used for that.

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.

4 participants