fix(iroh): Clean up mapped addresses when unused - #4447
Open
flub wants to merge 2 commits into
Open
Conversation
This adds some cleanup for when a mapped address is no longer used. Cleaning it up immediately would mean we generate new mapped addresses for endpoints if we come back to them. But also growing them unlimited does eventually result in a memory leak. So the compromise is that when an endpoint does not use too many remote endpoints they are all remembered. But once over the threshold we start removing unused addresses. This of course leaves up to the threshold addresses allocated that may never ever be used again. It's not ideal, but also doing this better would require a lot more bookkeeping.
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/4447/docs/iroh/ Last updated: 2026-07-28T15:55:51Z |
4 tasks
Contributor
|
I think there is a problem with this cleanup approach. Connections via relay are not guaranteed to result in a RemoteStateActor. E.g. if you send random garbage via a relay connection, the mappings will never be cleaned up. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This adds some cleanup for when a mapped address is no longer
used. Cleaning it up immediately would mean we generate new mapped
addresses for endpoints if we come back to them. But also growing them
unlimited does eventually result in a memory leak.
So the compromise is that when an endpoint does not use too many
remote endpoints they are all remembered. But once over the threshold
we start removing unused addresses.
This of course leaves up to the threshold addresses allocated that may
never ever be used again. It's not ideal, but also doing this better
would require a lot more bookkeeping.
Breaking Changes
n/a
Notes & open questions
Maybe 64 is a bit much, 32 would probably also be plenty.
I'm not sure what to do with custom mapped addrs. It seems like they
would also need cleanup but they don't currently store an
EndpointId. Perhaps the generic AddrMap needs to enforce that an
EndpointId is in the key somehow. I don't really understand how this
works currently for custom addresses.
Replaces fix(iroh): evict cached mapped addrs when a RemoteStateActor shuts down #4294 that is abandoned.
Change checklist
proposed change and wrote an as clear and concise description as
they could.
intented effect.