Skip to content

fix!(proto): Deprecate UdpStats::ios as io-operations can't be measured from this crate - #725

Merged
divagant-martian merged 11 commits into
mainfrom
overcounted-udp-rx-ios
Jun 30, 2026
Merged

divagant-martian merged 11 commits into
mainfrom
overcounted-udp-rx-ios

Conversation

@divagant-martian

@divagant-martian divagant-martian commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Closes #727
Deprecates ios in UdpStats. It's a bit of a shame that UdpStats is shared by so many places, path's sending stats, receiving stats, connection-wide send and recv stats. There is no field that captures something like this and makes sense across all of them, so adding it would make for a structural change.

This field was clearly added to test gso batching: a connection-wide sending stat. This is the only place where this is meaningful, so to be able to continue testing this, a test only field is added to the connection stats.

Breaking Changes

Notes & open questions

If anyone seriously cares about this, we should know thanks to the deprecation warning, and would prompt us to add something that better fits with the rest of the stats.

Whatever we do won't just be a undo of this PR as counting doesn't make sense in the rest of places, and the name is misleading. Basically, the deprecation warning should allow us to decide whether a larger change is required to get the gso_batches (what the field actually tried to measure, as noted by the tests) or if it can be cleanly removed. I'm tempted to say the latter, as I don't think users care too much about this.

Now, if they do want a count of io operations, that's an entirely different approach that requires interaction with the AsyncUdpSocket.

Change checklist

  • Self-review.
  • Breaking changes documented.

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Performance Comparison Report

22beec5b8747d02722ad95e33d7211685c91a114 - artifacts

No results available

---
f695e4394a12c0ece2b6f7a208e6793593c72e73 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5256.0 Mbps 7947.4 Mbps -33.9% 97.4% / 98.7%
medium-concurrent 5538.6 Mbps 7774.8 Mbps -28.8% 96.1% / 97.7%
medium-single 4032.5 Mbps 4470.4 Mbps -9.8% 96.5% / 98.4%
small-concurrent 3889.9 Mbps 5135.4 Mbps -24.3% 98.0% / 100.0%
small-single 3497.6 Mbps 4584.4 Mbps -23.7% 95.4% / 97.8%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3086.4 Mbps 4022.9 Mbps -23.3%
lan 782.4 Mbps 803.8 Mbps -2.7%
lossy 55.9 Mbps 69.8 Mbps -20.0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 24.8% slower on average

---
5f02c8afa0cb1989d58eb53083299a22356488d0 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5878.0 Mbps 7878.1 Mbps -25.4% 97.5% / 98.8%
medium-concurrent 5493.0 Mbps 7788.0 Mbps -29.5% 96.5% / 98.0%
medium-single 3942.6 Mbps 4730.2 Mbps -16.7% 96.7% / 98.6%
small-concurrent 3842.6 Mbps 5142.5 Mbps -25.3% 97.6% / 99.7%
small-single 3572.0 Mbps 4666.6 Mbps -23.5% 96.1% / 98.4%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3044.8 Mbps 4078.5 Mbps -25.3%
lan 782.4 Mbps 810.4 Mbps -3.5%
lossy 69.8 Mbps 59.1 Mbps +18.1%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 24.2% slower on average

---
7a250193b815723e5cd55480a6340203a4765100 - artifacts

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3044.7 Mbps 4064.7 Mbps -25.1%

Summary

noq is 25.1% slower on average

---
3d5eafbe02cca887f2a431e64f51e0bd150cac32 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5333.8 Mbps 7847.4 Mbps -32.0% 94.4% / 98.9%
medium-concurrent 5391.9 Mbps 7642.5 Mbps -29.4% 96.7% / 147.0%
medium-single 4039.8 Mbps 4692.0 Mbps -13.9% 98.7% / 151.0%
small-concurrent 3800.7 Mbps 5210.9 Mbps -27.1% 95.1% / 103.0%
small-single 3460.9 Mbps 4760.4 Mbps -27.3% 93.1% / 103.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3004.3 Mbps 4026.1 Mbps -25.4%
lan 782.4 Mbps 796.4 Mbps -1.8%
lossy 69.8 Mbps 69.8 Mbps ~0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 26.1% slower on average

---
4554ec84d345d853a93e5d43daeca32342c09141 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5442.2 Mbps 7797.1 Mbps -30.2% 96.6% / 98.2%
medium-concurrent 5366.7 Mbps 7814.1 Mbps -31.3% 96.0% / 97.6%
medium-single 3811.4 Mbps 4469.8 Mbps -14.7% 95.4% / 97.7%
small-concurrent 3767.6 Mbps 5058.3 Mbps -25.5% 97.9% / 99.8%
small-single 3484.3 Mbps 4612.5 Mbps -24.5% 95.4% / 97.6%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3047.9 Mbps 4063.9 Mbps -25.0%
lan 782.4 Mbps 810.4 Mbps -3.5%
lossy 69.9 Mbps 55.9 Mbps +25.0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 25.6% slower on average

---
ad24634efa38022b4ebb17b0e2f018c00e427dde - artifacts

No results available

---
7cac462375c9d781a79927234faef9c03f9633b5 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5499.9 Mbps 7919.1 Mbps -30.5% 97.3% / 98.7%
medium-concurrent 5363.3 Mbps 7861.0 Mbps -31.8% 96.3% / 97.8%
medium-single 3794.4 Mbps 4488.5 Mbps -15.5% 97.0% / 99.5%
small-concurrent 3904.5 Mbps 5304.8 Mbps -26.4% 97.8% / 100.0%
small-single 3468.5 Mbps 4778.3 Mbps -27.4% 95.8% / 98.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3022.5 Mbps 3973.1 Mbps -23.9%
lan 782.4 Mbps 810.3 Mbps -3.4%
lossy 69.8 Mbps 55.9 Mbps +25.0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 26.3% slower on average

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

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

Last updated: 2026-06-30T17:04:47Z

@n0bot n0bot Bot added this to iroh Jun 25, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Jun 25, 2026

@matheus23 matheus23 left a comment

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.

Would be neat to take our learnings about the nuance of stats to the doc comments of said stats.

E.g. we could add the invariants we expect (ios <= datagrams) to the docstring, and the fact that discarded datagrams are not counted towards ios or datagrams.

Comment thread noq-proto/src/connection/mod.rs Resolved
Comment thread noq-proto/src/tests/mod.rs Resolved
Comment thread noq-proto/src/connection/mod.rs Resolved
@divagant-martian

Copy link
Copy Markdown
Collaborator Author

The more I check these UdpStats the less sense they make.

@divagant-martian
divagant-martian marked this pull request as draft June 27, 2026 14:40
@matheus23

Copy link
Copy Markdown
Member

Should we mark them as deprecated? (Is un-deprecating a public API a non-breaking change, in case we can make it work in the future?)

@flub

flub commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

i guess un-deprecating is not a breaking change

@divagant-martian divagant-martian changed the title fix(proto): count udp_rx.ios per udp datagram instead of quic packet fix!(proto): Deprecate UdpStats::ios as io-operations can't be measured from this crate Jun 30, 2026
@divagant-martian
divagant-martian marked this pull request as ready for review June 30, 2026 14:32
@divagant-martian

Copy link
Copy Markdown
Collaborator Author

A whole different turn on this PR, so I'm requesting review again. I updated the description so please check that beforehand

@flub

flub commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Basically, the deprecation warning should allow us to decide whether a larger change is required to get the gso_batches (what the field actually tried to measure, as noted by the tests) or if it can be cleanly removed. I'm tempted to say the latter, as I don't think users care too much about this.

With my SRE hat on I do care about such a metric. I'd probably want it as a histogram of GSO batch sizes. On a busy server serving one particular kind of traffic (one service) that will give me pretty good insight into how well things are working. And if the hardware suddenly stops doing GSO or something (because it's moved to a different node on k8s probably) then I'd find out.

Having said that, I'm not against removing this here. Just adding perspective of how this can be useful.

@divagant-martian

Copy link
Copy Markdown
Collaborator Author

I'd probably want it as a histogram of GSO batch sizes. (..) Just adding perspective of how this can be useful.

Would you be able to get this, beside a lousey approximation? you get a counter of gso_batches and total sent bytes, on each call you do to stats, so at best you can do some arithmetic over your last data point and get an average. The only way of achieving this, getting an accurate reading, would be talking with the socket (AsyncUdpSocket) so that you get the correct data point, and each data point, which via stats isn't possible.

So my point is, this has been here for a good while, and has not had any use, in particular no that one use you mention, on the other achieving what you want gso batch sizes isn't even really achievable with what we had.

@flub flub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Logically I think this is good, though I think the gso_batches name is rather on the odd side.

Comment thread noq-proto/src/connection/stats.rs Resolved
Comment thread noq-proto/src/connection/stats.rs Resolved
@flub

flub commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

I'd probably want it as a histogram of GSO batch sizes. (..) Just adding perspective of how this can be useful.

Would you be able to get this, beside a lousey approximation? you get a counter of gso_batches and total sent bytes, on each call you do to stats, so at best you can do some arithmetic over your last data point and get an average. The only way of achieving this, getting an accurate reading, would be talking with the socket (AsyncUdpSocket) so that you get the correct data point, and each data point, which via stats isn't possible.

Indeed. There's nothing noq can do here because it only has counters. And it can't really do histograms because the user should be in charge of the bucket sizes etc. At best a commonly accepted abstraction like metrics-rs could work, but that's never gained any traction anywhere sadly. But indeed wrapping it up in an AsyncUdpSocket would be a workaround for this.

So my point is, this has been here for a good while, and has not had any use, in particular no that one use you mention, on the other achieving what you want gso batch sizes isn't even really achievable with what we had.

Yeah, totally. Which is why I agree this PR is the right thing to do.

@divagant-martian
divagant-martian requested a review from flub June 30, 2026 15:40
Comment thread noq-proto/src/connection/stats.rs Resolved
@divagant-martian
divagant-martian added this pull request to the merge queue Jun 30, 2026
Merged via the queue into main with commit d6e525d Jun 30, 2026
38 of 39 checks passed
@divagant-martian
divagant-martian deleted the overcounted-udp-rx-ios branch June 30, 2026 17:16
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh Jun 30, 2026
Stanley00 pushed a commit to stanley-fork/noq that referenced this pull request Jul 13, 2026
## Description

This updates semver checks with the following behaviour:

- The baseline for the check is now the latest published release on
  crates.io

- If you make a semver-breaking change you must also bump the package
  version number so that the semver check will pass. Because we like
  to bump the versions of all crates at the same time you can not use
  pre-releases since cargo does not allow mixing those and the iroh
  patchbay tests has 2nd-level dependencies on noq-udp (via netwatch).

- Adding deprecated items is allowed in minor version bumps, matching
  https://semver.org/#how-should-i-handle-deprecating-functionality

- Bump noq-proto version because we previously added deprecations.

- Now the baseline is somewhat stable, enable caching.


## Breaking Changes

none

## Notes & open questions

I tested this first by not bumping the noq-proto version number and it
fails in that case. Which is due to n0-computer#725.

Once this is merged I will make the semver check required in noq.

The version bumping required to make semver-checks pass could be a bit
annoying. It will also make patching iroh for noq a little bit harder.
As shown by what the patchbay check has to do now. I'm tempted to think
for now that this is worth it, but happy to think about how to tweak
this as we gain experience.

OTOH having to bump to the right version means that come to a release we
do know what the next version should be. Which is probably good.

## Change checklist

- [x] Self-review.
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.

noq-proto should not count io operations

3 participants