Skip to content

fix(iroh): Clean up mapped addresses when unused - #4447

Open
flub wants to merge 2 commits into
mainfrom
flub/cleanup-mapped-addrs
Open

fix(iroh): Clean up mapped addresses when unused#4447
flub wants to merge 2 commits into
mainfrom
flub/cleanup-mapped-addrs

Conversation

@flub

@flub flub commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

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

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • This PR was created by a human that thought critically about the
    proposed change and wrote an as clear and concise description as
    they could.
  • This PR isn't slop, and is carefully crafted to do have the
    intented effect.

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.
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

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

@n0bot n0bot Bot added this to iroh Jul 28, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Jul 28, 2026
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 26d729a

@rklaehn

rklaehn commented Jul 29, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚑 Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants