Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Fix network memory leaks #687

Merged
merged 7 commits into from
Aug 8, 2022
Merged

Fix network memory leaks #687

merged 7 commits into from
Aug 8, 2022

Conversation

asonnino
Copy link
Contributor

@asonnino asonnino commented Aug 4, 2022

Fix memory leaks in the network stack when updating the committee (or changing epoch)

@asonnino asonnino requested a review from bmwill as a code owner August 4, 2022 22:33
@asonnino asonnino self-assigned this Aug 4, 2022
@asonnino asonnino linked an issue Aug 4, 2022 that may be closed by this pull request
@asonnino asonnino changed the title Fix-net-memory Fix network memory leaks Aug 4, 2022
Copy link
Contributor

@akichidis akichidis left a comment

Choose a reason for hiding this comment

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

I would like to have a look again on this, but don't have many comments. Tried to think of how we could probably implement in a different way (seems to me that we do similar stuff in many places) but can't think of something right now. In the meanwhile could you please sync with @arun-koshy as he is looking to extra the worker addresses from committee? It seems that you touch some similar stuff.

Comment on lines +468 to +477
authority
.workers
.values()
.map(|address| &address.worker_to_worker),
)
.chain(
authority
.workers
.values()
.map(|address| &address.primary_to_worker),
Copy link
Contributor

Choose a reason for hiding this comment

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

I see a possible conflict with @arun-koshy PR here #670 . You might want to coordinate on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can land this PR after #670 unless @bmwill thinks we need it soon for his new network?

Comment on lines +77 to 85
pub fn cleanup<'a, I>(&mut self, to_remove: I)
where
I: IntoIterator<Item = &'a Multiaddr>,
{
for address in to_remove {
self.clients.remove(address);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add tests for this behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@huitseeker Do you think this function could be in a nice trait? It is used by 3 out of 4 of our network structs

Copy link
Contributor

Choose a reason for hiding this comment

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

@asonnino The natural place to add it is the BaseNetwork trait.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But not all networks can have this functions. To be precise, they all need it except WorkerToPrimary that only has a single client.

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

Same comment on get_all_network_addresses, otherwise LGTM. Please link to #566, which you're closing.

Comment on lines +77 to 85
pub fn cleanup<'a, I>(&mut self, to_remove: I)
where
I: IntoIterator<Item = &'a Multiaddr>,
{
for address in to_remove {
self.clients.remove(address);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@asonnino The natural place to add it is the BaseNetwork trait.

Comment on lines 484 to 486
/// Return the network addresses that are present in the current committee but that are absent
/// from the new committee (provided as argument).
pub fn network_diff<'a>(&'a self, new_committee: &'a Self) -> HashSet<&Multiaddr> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: new and old are concepts for the caller of this method. The typical way to present things in such a method is self and other (for the argument).

@huitseeker
Copy link
Contributor

@asonnino You'll want to rebase as we have fixed your cargo-deny issue on main.

@asonnino asonnino merged commit c6267f2 into main Aug 8, 2022
@asonnino asonnino deleted the fix-net-memory branch August 8, 2022 13:54
huitseeker pushed a commit to huitseeker/narwhal that referenced this pull request Aug 8, 2022
@huitseeker huitseeker mentioned this pull request Aug 8, 2022
huitseeker pushed a commit that referenced this pull request Aug 8, 2022
Facility to cleanup network
huitseeker pushed a commit that referenced this pull request Aug 12, 2022
Facility to cleanup network
mwtian pushed a commit to mwtian/sui that referenced this pull request Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup Network
4 participants