Skip to content

chore(proto): Update to rand 0.10#511

Merged
matheus23 merged 10 commits into
mainfrom
matheus23/rand-0.10
Mar 23, 2026
Merged

chore(proto): Update to rand 0.10#511
matheus23 merged 10 commits into
mainfrom
matheus23/rand-0.10

Conversation

@matheus23
Copy link
Copy Markdown
Member

@matheus23 matheus23 commented Mar 17, 2026

Description

This updates noq and its dependencies to rand 0.10 and getrandom 0.4.

Breaking Changes

I don't think there are any of rand's APIs exposed in noq or noq-proto. So no breaking changes.

Notes & open questions

Blocked on tomtomwombat/fastbloom#27 being released. We can disable the rand feature for fastbloom instead.

proptest still depends on rand 0.9:

$ cargo tree -i rand@0.9
rand v0.9.2
└── proptest v1.9.0
    [dev-dependencies]
    └── noq-proto v0.16.0 (/home/philipp/program/work/noq/noq-proto)
        ├── noq v0.17.0 (/home/philipp/program/work/noq/noq)
        │   ├── bench v0.2.0 (/home/philipp/program/work/noq/bench)
        │   └── perf v0.2.0 (/home/philipp/program/work/noq/perf)
        └── perf v0.2.0 (/home/philipp/program/work/noq/perf)

But it's only a dev-dependency, so won't get pulled in for people depending on noq.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 17, 2026

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

Last updated: 2026-03-23T10:24:54Z

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 17, 2026

Performance Comparison Report

30974f65cb6b292a487d767103dd3a4d22951214 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5284.7 Mbps 8128.1 Mbps -35.0% 93.9% / 107.0%
medium-concurrent 5243.9 Mbps 7936.4 Mbps -33.9% 94.5% / 106.0%
medium-single 4107.1 Mbps 4749.5 Mbps -13.5% 96.2% / 111.0%
small-concurrent 3664.5 Mbps 5329.5 Mbps -31.2% 99.6% / 165.0%
small-single 3573.1 Mbps 4823.2 Mbps -25.9% 94.2% / 107.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal N/A 3645.2 Mbps N/A
lan N/A 796.4 Mbps N/A
lossy N/A 55.9 Mbps N/A
wan N/A 83.8 Mbps N/A

Summary

noq is 29.4% slower on average

---
7acdd52faeeeff1af3086ea0fb98dacc35e42069 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 6111.5 Mbps 8066.3 Mbps -24.2% 97.4% / 99.0%
medium-concurrent 5472.1 Mbps 8064.7 Mbps -32.1% 96.3% / 98.0%
medium-single 4362.0 Mbps 4681.1 Mbps -6.8% 96.2% / 98.5%
small-concurrent 3994.1 Mbps 5077.8 Mbps -21.3% 97.5% / 99.6%
small-single 3641.7 Mbps 4774.7 Mbps -23.7% 96.3% / 98.6%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3072.5 Mbps 3645.7 Mbps -15.7%
lan 782.4 Mbps 796.4 Mbps -1.8%
lossy 69.9 Mbps 55.9 Mbps +25.0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 21.7% slower on average

---
add1fe3150f5f37b35477f1784ad260cd0b20b21 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 6070.2 Mbps 8001.8 Mbps -24.1% 98.3% / 99.4%
medium-concurrent 5599.2 Mbps 7878.4 Mbps -28.9% 96.6% / 98.0%
medium-single 4098.8 Mbps 4620.9 Mbps -11.3% 96.8% / 99.1%
small-concurrent 4008.4 Mbps 5224.1 Mbps -23.3% 97.4% / 99.7%
small-single 3571.1 Mbps 4587.9 Mbps -22.2% 97.3% / 99.2%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal N/A 3708.5 Mbps N/A
lan N/A 796.4 Mbps N/A
lossy N/A 69.8 Mbps N/A
wan N/A 83.8 Mbps N/A

Summary

noq is 23.0% slower on average

---
636ed2b28aaf1ad3048cf4b8edddac5bc4edce06 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5946.3 Mbps 7864.6 Mbps -24.4% 97.0% / 107.0%
medium-concurrent 5798.7 Mbps 7680.8 Mbps -24.5% 96.0% / 108.0%
medium-single 3584.7 Mbps 4749.2 Mbps -24.5% 89.7% / 97.7%
small-concurrent 3943.1 Mbps 5222.0 Mbps -24.5% 92.1% / 99.5%
small-single 3611.9 Mbps 4796.7 Mbps -24.7% 95.7% / 110.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3149.5 Mbps 3952.8 Mbps -20.3%
lan 782.4 Mbps 800.1 Mbps -2.2%
lossy 69.9 Mbps 55.9 Mbps +25.0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 23.4% slower on average

---
c8e6e7bf0002f67511940d60f466af6dcb7312da - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5678.1 Mbps 8103.6 Mbps -29.9% 95.2% / 108.0%
medium-concurrent 5702.6 Mbps 7669.3 Mbps -25.6% 92.3% / 97.1%
medium-single 4111.9 Mbps 4749.6 Mbps -13.4% 89.0% / 97.1%
small-concurrent 3938.3 Mbps 5393.1 Mbps -27.0% 100.1% / 165.0%
small-single 3582.5 Mbps 4833.3 Mbps -25.9% 96.4% / 110.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 2960.8 Mbps 3967.0 Mbps -25.4%
lan 782.5 Mbps 810.4 Mbps -3.4%
lossy 69.8 Mbps 55.9 Mbps +25.0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 24.5% slower on average

---
c8d765ab1ef6bd17178855b5c4397f15c2e8dd96 - artifacts

No results available

---
dcbcfdc6c6ba22367d2863c65014390389ef19ee - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 6068.1 Mbps 7934.1 Mbps -23.5% 98.2% / 99.4%
medium-concurrent 5969.9 Mbps 7657.1 Mbps -22.0% 96.6% / 98.3%
medium-single 4115.9 Mbps 4679.3 Mbps -12.0% 96.5% / 98.6%
small-concurrent 3933.2 Mbps 5240.3 Mbps -24.9% 96.6% / 99.5%
small-single 3693.4 Mbps 4776.3 Mbps -22.7% 99.1% / 100.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 2967.0 Mbps 3652.2 Mbps -18.8%
lan 782.5 Mbps 807.2 Mbps -3.1%
lossy 69.8 Mbps 69.9 Mbps ~0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 20.7% slower on average

---
6cc2001a30ae4b6b61c399437119bda3a5842cb7 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5443.0 Mbps 8191.9 Mbps -33.6% 91.7% / 97.4%
medium-concurrent 5780.6 Mbps 7391.8 Mbps -21.8% 94.5% / 104.0%
medium-single 3583.0 Mbps 4375.9 Mbps -18.1% 86.8% / 96.3%
small-concurrent 3901.8 Mbps 4869.9 Mbps -19.9% 90.3% / 98.4%
small-single 3410.9 Mbps 4408.1 Mbps -22.6% 86.8% / 95.6%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3117.6 Mbps 4002.8 Mbps -22.1%
lan 782.4 Mbps 810.3 Mbps -3.4%
lossy 69.8 Mbps 69.8 Mbps ~0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 23.5% slower on average

---
4746c17998e20d7cb291e64570f8553569d2ee92 - artifacts

No results available

---
2b322b917750425233fd57b615ba1caae4ca1b2a - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5483.4 Mbps 8018.1 Mbps -31.6% 95.2% / 101.0%
medium-concurrent 5456.5 Mbps 7636.6 Mbps -28.5% 93.6% / 100.0%
medium-single 3889.7 Mbps 4749.1 Mbps -18.1% 91.4% / 100.0%
small-concurrent 3769.2 Mbps 5300.6 Mbps -28.9% 95.3% / 125.0%
small-single 3522.7 Mbps 4650.3 Mbps -24.2% 87.8% / 97.1%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3073.1 Mbps 4004.6 Mbps -23.3%
lan 782.4 Mbps 810.4 Mbps -3.5%
lossy 69.9 Mbps 56.9 Mbps +22.7%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 26.0% slower on average

@matheus23 matheus23 force-pushed the matheus23/rand-0.10 branch from 7acdd52 to add1fe3 Compare March 20, 2026 09:45
@matheus23 matheus23 marked this pull request as ready for review March 20, 2026 10:18
@matheus23
Copy link
Copy Markdown
Member Author

Switching this to ready for review, because that's what it is, even if it's blocked on a release of fastbloom.

@matheus23 matheus23 force-pushed the matheus23/rand-0.10 branch from 636ed2b to c8e6e7b Compare March 20, 2026 15:47
Comment thread Cargo.lock
"noq-udp",
"pin-project-lite",
"rand",
"rand 0.10.0",
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.

Looks like there's still a dup rand?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is only due to the proptest dev-dependency:

$ cargo tree -i rand@0.9
rand v0.9.2
└── proptest v1.9.0
    [dev-dependencies]
    └── noq-proto v0.16.0 (/home/philipp/program/work/noq/noq-proto)
        ├── noq v0.17.0 (/home/philipp/program/work/noq/noq)
        │   ├── bench v0.2.0 (/home/philipp/program/work/noq/bench)
        │   └── perf v0.2.0 (/home/philipp/program/work/noq/perf)
        └── perf v0.2.0 (/home/philipp/program/work/noq/perf)

let mut rand_index = self
.random_number_generator
.random_range(0..K_PACING_GAIN.len() as u8 - 1);
let mut rand_index = rand::rng().random_range(0..K_PACING_GAIN.len() as u8 - 1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is very unfortunate, I know we are planning on removing it, but we would need this back later, for proper seeded testing :/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I know - but the previous version of this code didn't allow passing in the randomness or a seed either, so this is no regression in that sense.

I'm aware of this issue in general, but fixing this would be annoying and blow up the diff in this PR.

Comment thread noq-proto/src/endpoint.rs
rng: config
.rng_seed
.map_or_else(StdRng::from_os_rng, StdRng::from_seed),
.map_or_else(|| StdRng::from_rng(&mut rand::rng()), StdRng::from_seed),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's the benefit of StdRng over rand::rng?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

StdRng is generally meant to be a fast in-memory rng. At the moment internally it's implemented using chacha. IIUC, rand::rng() pulls in randomness from the OS, if there wasn't any randomness on this thread yet.

Comment thread noq-proto/Cargo.toml

[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dev-dependencies]
# ensure we set the wasm_js feature even for the older version of getrandom used in proptest in Wasm
getrandom_0_3 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • so we have to enforce using both getrandom 0.3 and 0.4 in our tree atm?
  • is there now flag on getrandom 0.4 we need to set anymore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is only in dev-dependencies, and only because we still depend on proptest, and we run some tests in Wasm that depend on proptest (although we don't run proptests themselves). This is a trade-off we made a while ago to make cfg-ing proptest things everywhere not necessary.


use rand::{Rng, RngCore};
use rand::Rng;
use rand::RngExt;
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.

What's with our formatter? It is on strike?

(genuinely the dig is at our tooling, this is not something you should have to handle)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah - weirdly enough running cargo make format doesn't seem to change this code 🤔

let mut rand_index = self
.random_number_generator
.random_range(0..K_PACING_GAIN.len() as u8 - 1);
let mut rand_index = rand::rng().random_range(0..K_PACING_GAIN.len() as u8 - 1);
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.

Are you not losing the option to be deterministic by doing this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You never had the option to configure this congestion controller to be deterministic in the first place, so no.

@matheus23 matheus23 enabled auto-merge March 23, 2026 10:27
@matheus23 matheus23 added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit 1280ffd Mar 23, 2026
36 checks passed
@matheus23 matheus23 deleted the matheus23/rand-0.10 branch March 23, 2026 10:56
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh Mar 23, 2026
matheus23 added a commit to n0-computer/iroh that referenced this pull request Mar 30, 2026
## Description

Updates the `rand` dependency to version 0.10.
As part of that, this also updates `rand_core`, `rand_chacha`, and a
bunch of cryptography crates like `curve25519-dalek`, `ed25519-dalek`,
`digest`, `sha1` and `sha2`. Some of the latter ones to prerelease
versions to enable compilation.

## Breaking Changes

- `iroh::SecretKey::generate`'s `CryptoRng` parameter is now updated
from rand 0.9 to rand 0.10

## Notes & open questions

Although this is ready for review, it's not ready to be merged yet,
because of patched dependencies.

This is the current TODO list:
- [x] ~~fastbloom needs to update to rand 0.10 and make a new release:
tomtomwombat/fastbloom#27 (we can just disable
fastbloom's rand feature)
- [x] noq will need to merge n0-computer/noq#511
once unblocked from fastbloom
- [x] swarm-discovery needs updating to hickory 0.26
rkuhn/swarm-discovery#21
- [x] portmapper will need to merge
n0-computer/net-tools#118
- [x] tokio-websockets has released with rand 0.10 support
- [x] igd-next has released with rand 0.10 support
- [x] And finally, hickory has released [a first beta for version
0.26](https://docs.rs/crate/hickory-resolver/0.26.0-beta.1), but it has
*a lot* of API changes and I'm working towards adjusting iroh code to
them.

## Change checklist
<!-- Remove any that are not relevant. -->
- [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.

3 participants