Skip to content

fix(proto): ensure stats reported in Discarded events are updated#728

Merged
divagant-martian merged 1 commit into
mainfrom
outdated-discarded-stats
Jun 29, 2026
Merged

fix(proto): ensure stats reported in Discarded events are updated#728
divagant-martian merged 1 commit into
mainfrom
outdated-discarded-stats

Conversation

@divagant-martian

@divagant-martian divagant-martian commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Description

PathStats has a lot of values that are cumulative counters and so, those are
updated as their respective actions are performed. Some other values, like rtt,
are snapshots: views of the current state, and so, are only updated on demand.
When a path is discarded, it used to call Connection::path_stats which
performs the update, but it was lost in a refactor. As a consequence, those
values were no longer being updated before the final stats were returned in the
Discarded event, despite the comment explaining the need to do so remaining
in the code.

This fixes the issue by updating the stats and adds a test. Yes, it's a stats
only test, but the fact this was properly done at some point and regressed
later is evidence this is needed.

Small consequence is that the return type of PathStatsMap::discard is no
longer needed/useful.

Breaking Changes

n/a

Notes & open questions

n/a

Change checklist

  • Self-review.
  • Tests if relevant.

@divagant-martian divagant-martian added this to the noq: iroh v1.0 + 1 milestone Jun 28, 2026
@divagant-martian divagant-martian self-assigned this Jun 28, 2026
@github-actions

Copy link
Copy Markdown

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

Last updated: 2026-06-28T13:30:30Z

@divagant-martian divagant-martian linked an issue Jun 28, 2026 that may be closed by this pull request
@n0bot n0bot Bot added this to iroh Jun 28, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Jun 28, 2026
@github-actions

Copy link
Copy Markdown

Performance Comparison Report

656f2d0c62f02417570b3796c845ff890424a3d7 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5455.9 Mbps 7962.7 Mbps -31.5% 95.1% / 100.0%
medium-concurrent 5434.4 Mbps 7877.6 Mbps -31.0% 94.6% / 100.0%
medium-single 3813.4 Mbps 4550.6 Mbps -16.2% 97.1% / 153.0%
small-concurrent 3867.9 Mbps 5322.5 Mbps -27.3% 90.4% / 98.9%
small-single 3500.7 Mbps 4653.7 Mbps -24.8% 89.8% / 97.7%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3067.7 Mbps 4028.6 Mbps -23.9%
lan 796.3 Mbps 805.2 Mbps -1.1%
lossy 69.9 Mbps 69.8 Mbps ~0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 26.2% slower on average

Comment on lines +3391 to +3393
// This ensures snapshot values (like rtt) are properly updated.
let path_stats = self.path_stats(path_id).unwrap_or_default();
self.path_stats.discard(&path_id);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oof this took me a while to realize that self.path_stats is doing a lot more than just return path stats, and self.path_stats.discard can't just do this work for me.

Thanks, nice catch!

@divagant-martian divagant-martian added this pull request to the merge queue Jun 29, 2026
Merged via the queue into main with commit 288323b Jun 29, 2026
39 checks passed
@divagant-martian divagant-martian deleted the outdated-discarded-stats branch June 29, 2026 07:15
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

PathEvent::Discarded carries outdated stats

2 participants