Skip to content

feat(iroh): Retain stats for closed and abandoned paths in the path watcher#3899

Open
Frando wants to merge 16 commits intomainfrom
Frando/pathwatch
Open

feat(iroh): Retain stats for closed and abandoned paths in the path watcher#3899
Frando wants to merge 16 commits intomainfrom
Frando/pathwatch

Conversation

@Frando
Copy link
Member

@Frando Frando commented Jan 29, 2026

Description

Depends on n0-computer/quinn#386

Improves the path watcher for connections to reliably allow accessing the stats of abandoned paths.

  • Abandoned paths are not removed from the value of the watchable for a connection's paths, as long as there are active watchers (subscribers)
  • Only once all watchers are dropped, we drop the abandoned paths from the watchable's value on the next update
  • This means that if you keep a PathWatcher alive for the duration of a connection, it will contain all paths the connection ever used.
  • We use the changes from feat: Retain final path stats if a Path is alive, add WeakPathHandle quinn#386 and keep a WeakPathHandle for all paths in the watchable's value. This prevents the path stats to be dropped within a quinn connection even if the path is abandoned.
  • We do no longer store path stats anywhere in iroh directly, but only ever access them from quinn. Due to keeping the WeakPathHandle, we can ensure that the stats are always available as long as the connection hasn't been dropped.

The combination of all this gives us a reliable way to access final path stats for all paths used in a connection, as long as you keep a reference to the connection around, which is quite straightforward to do and document.

Breaking Changes

  • Connection::paths and ConnectionInfo::paths now return a PathWatcher (which still implements n0_watcher::Watcher but now also is a named struct)
  • PathInfo::stats and PathInfo::rtt now return Option. They return None if the underlying connection has been droped.

Notes & open questions

I spend quite some time going back-and-forth over different approaches. Very open to other ideas, but I'm a bit out of further ideas currently and this is the best I could come up with so far.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.
    • List all breaking changes in the above "Breaking Changes" section.
    • Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are:

@Frando Frando force-pushed the Frando/pathwatch branch 2 times, most recently from 6bf73fc to ed10e46 Compare January 29, 2026 14:51
@n0bot n0bot bot added this to iroh Jan 29, 2026
@github-project-automation github-project-automation bot moved this to 🚑 Needs Triage in iroh Jan 29, 2026
@Frando Frando marked this pull request as draft January 29, 2026 15:43
@github-actions
Copy link

github-actions bot commented Jan 30, 2026

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3899/docs/iroh/

Last updated: 2026-02-05T08:44:28Z

@Frando Frando changed the title wip: path watcher feat(iroh): Allow to access stats for closed and abandoned paths in the path watcher Feb 3, 2026
@Frando Frando changed the title feat(iroh): Allow to access stats for closed and abandoned paths in the path watcher feat(iroh): Retain stats for closed and abandoned paths in the path watcher Feb 3, 2026
@Frando Frando marked this pull request as ready for review February 3, 2026 10:04
@dignifiedquire dignifiedquire moved this from 🚑 Needs Triage to 🏗 In progress in iroh Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

1 participant