-
Notifications
You must be signed in to change notification settings - Fork 317
feat: prune old, inactive paths #3666
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
base: feat-multipath
Are you sure you want to change the base?
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3666/docs/iroh/ Last updated: 2025-11-20T17:10:25Z |
…` method, and called it whenever new paths are added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err.. I think this file should be removed probably. I think it's from a stray merge, right?
| self.paths | ||
| .insert(path_remote, Source::Connection { _0: Private }); | ||
| self.select_path(); | ||
| // TODO(ramfox): do we need to prune paths here? | ||
| self.prune_ip_paths(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
I think every time we call paths.insert we should also call self.prune_ip_paths(). Because the number of paths might get increased above the high watermark due to the insert.
|
|
||
| trace!("ping received, triggering holepunching"); | ||
| self.trigger_holepunching().await; | ||
| // TODO(ramfox): potentially prune addrs here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think we should do so here, since we have paths.inserted above.
| self.paths.disco_ping_sent(addr.clone(), msg.tx_id); | ||
| self.send_disco_message(addr, disco::Message::Ping(msg)) | ||
| .await; | ||
| // TODO(ramfox): potentially prune addrs here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't think so. We only need to prevent the paths from becoming excessively populated. We can prevent that by checking each time we paths.insert.
| if self.paths.len() < MAX_INACTIVE_IP_ADDRESSES { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've already done this check in RemoteStateActor::prune_ip_paths.
I think I'd be in favor of removing this check and inlining the prune_ip_paths call below.
…unched this connection
Description
Prune paths that are not actively being used, about to be dialed, or old.
Notes and Questions
The logic of gathering all of the relevant information is in the
fn prune_ip_pathsfunction, not in theself.prune_ip_pathsmethod onEndpointActorState. Separating these out made it easier to test.Used AI to help write tests & reduce allocations when working through the paths.
keep_pathis where we can play around in the future with what exactly we want to keep, based on thePathState, if we want to get more strict or particular as we learn more.Right now we:
This means:
Also, we only do prune this if there are more that 20 inactive paths open.
I've added
prune_ip_pathsanytime we insert a path to theEndpointActorState::paths. However, there are two places I did not add this check, that maybe I should. But my brain is a bit fuzzy right now, so I will do another review about where these checks should go.That being said, I think this is ready for initial review, at least.