Skip to content

update getrandom to 0.4#177

Merged
GuillaumeLagrange merged 3 commits into
CodSpeedHQ:mainfrom
Ludea:getrandom
Jun 23, 2026
Merged

update getrandom to 0.4#177
GuillaumeLagrange merged 3 commits into
CodSpeedHQ:mainfrom
Ludea:getrandom

Conversation

@Ludea

@Ludea Ludea commented Apr 23, 2026

Copy link
Copy Markdown

Update getrandom to 0.4

@xtqqczze

xtqqczze commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Maybe we don't want a duplicate getrandom dependency?

getrandom v0.2.15
└── rand_core v0.6.4
    ├── rand v0.8.5
    │   └── quickcheck v1.0.3
    │       [dev-dependencies]
    │       └── codspeed-criterion-compat-walltime v4.5.0
    │           └── codspeed-criterion-compat v4.5.0
    │   [dev-dependencies]
    │   └── codspeed-criterion-compat-walltime v4.5.0 (*)
    └── rand_chacha v0.3.1
        └── rand v0.8.5 (*)

@GuillaumeLagrange

Copy link
Copy Markdown
Contributor

Hello @Ludea
What's the overall motivation behind bumping getrandom?

Unless there's a CVE, I don't think bumping dependencies without a particular motivation is really useful. Not dismissing the PR, there maybe is a completely valid reason

As for the double dependency, yes it's an issue we should try to avoid, although this repo contains snapshots of the upstream libraries for both divan and criterion, the closer we stay to their trunk the better. This is definitely something we could improve in the repo structure.

@Ludea

Ludea commented Apr 28, 2026

Copy link
Copy Markdown
Author

0.4 support wasip{1, 2 3} target (even if wasip3 is not yet released.

With updating to this version, we can use this lib on these target.

I don't use directly codspeed but a lib which depend on it.

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR upgrades getrandom from 0.2 to 0.4 across the workspace and bumps the MSRV from 1.80 to 1.85 (required by getrandom 0.4) and the development toolchain from 1.88 to 1.96.

  • Core API update: getrandom::getrandom(&mut bytes)getrandom::fill(&mut bytes) in crates/codspeed/src/utils.rs; error handling is preserved unchanged.
  • Lint fixes across forks: explicit '_ lifetime annotations added to BenchmarkGroup, DisplayThroughput, and BenchOptions return types in the criterion and divan forks; iter::repeat().take() replaced with iter::repeat_n() (stable since 1.82); redundant parentheses removed in two sort_by closures.
  • Toolchain components: rustfmt, clippy, and rust-analyzer are now pinned in rust-toolchain.toml for consistent developer tooling.

Confidence Score: 5/5

Safe to merge — the getrandom API rename is mechanical and correct, and all secondary changes are compiler lint fixes with no functional impact.

All changes are straightforward: the getrandom::fill rename is the documented replacement for getrandom::getrandom in v0.4, the MSRV bump to 1.85 exactly matches getrandom 0.4's stated minimum, and the remaining changes are clippy/rustfmt housekeeping in the criterion and divan forks. Both getrandom versions coexist correctly in Cargo.lock because rand_core 0.6 still pins 0.2.

No files require special attention.

Important Files Changed

Filename Overview
crates/codspeed/src/utils.rs Updates getrandom call from deprecated getrandom::getrandom() to the new getrandom::fill() API introduced in 0.4; logic and error handling unchanged.
crates/codspeed/Cargo.toml Bumps getrandom dependency from 0.2 to 0.4 and raises MSRV from 1.80 to 1.85 — both changes are required by getrandom 0.4's minimum Rust version.
rust-toolchain.toml Bumps development toolchain channel from 1.88 to 1.96 and explicitly pins rustfmt, clippy, and rust-analyzer components for consistent developer tooling.
Cargo.lock Adds getrandom 0.4.3 (with its new r-efi transitive dependency for UEFI targets) alongside the existing getrandom 0.2.15 entry still required by rand_core 0.6.
crates/criterion_compat/benches/criterion_integration/with_inputs.rs Replaces iter::repeat(x).take(n) with iter::repeat_n(x, n) (stabilised in Rust 1.82); semantically equivalent, now valid under the new MSRV of 1.85.
crates/criterion_compat/src/compat/criterion.rs Makes the implicit lifetime in BenchmarkGroup return type explicit as BenchmarkGroup<'_, M> to satisfy newer clippy lints; no functional change.
crates/divan_compat/divan_fork/src/counter/any_counter.rs Adds explicit '_ lifetime to DisplayThroughput return type; pure lint fix with no functional change.
crates/divan_compat/divan_fork/src/entry/meta.rs Adds explicit '_ lifetime to Option<&BenchOptions> return type; pure lint fix with no functional change.
crates/divan_compat/divan_fork/src/entry/tree.rs Adds explicit '_ lifetime to BenchOptions generic in the return type; pure lint fix with no functional change.
crates/criterion_compat/criterion_fork/src/plot/gnuplot_backend/summary.rs Removes redundant parentheses around the sort_by closure body; style-only, no functional change.
crates/criterion_compat/criterion_fork/src/plot/plotters_backend/summary.rs Removes redundant parentheses around the sort_by closure body; style-only, no functional change.
crates/divan_compat/divan_fork/tests/weird_usage.rs Reorders use import items to satisfy rustfmt ordering rules; no functional change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[generate_unique_id] --> B["getrandom::fill(&mut bytes[16])"]
    B --> C{getrandom 0.4.3}
    C -->|Linux / macOS / Windows| D[OS entropy source]
    C -->|UEFI target| E[r-efi EFI_RNG_PROTOCOL]
    D --> F[16 random bytes]
    E --> F
    F --> G[Assemble UUID v4]
    G --> H["xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"]

    subgraph "Cargo.lock — two getrandom versions"
        I[getrandom 0.4.3 - codspeed crate]
        J[getrandom 0.2.15 - rand_core 0.6 unchanged]
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[generate_unique_id] --> B["getrandom::fill(&mut bytes[16])"]
    B --> C{getrandom 0.4.3}
    C -->|Linux / macOS / Windows| D[OS entropy source]
    C -->|UEFI target| E[r-efi EFI_RNG_PROTOCOL]
    D --> F[16 random bytes]
    E --> F
    F --> G[Assemble UUID v4]
    G --> H["xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"]

    subgraph "Cargo.lock — two getrandom versions"
        I[getrandom 0.4.3 - codspeed crate]
        J[getrandom 0.2.15 - rand_core 0.6 unchanged]
    end
Loading

Reviews (3): Last reviewed commit: "chore: bump repo toolchain to 1.96" | Re-trigger Greptile

@GuillaumeLagrange

Copy link
Copy Markdown
Contributor

Merging like this, the duplicate getrandom is just a dev dependency for criterion's test suite. As much as we can we try to not introduce diff to upstream libs to ease maintenance.

@codspeed-hq

codspeed-hq Bot commented Jun 23, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 6.38%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 62 improved benchmarks
❌ 52 regressed benchmarks
✅ 477 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime recursive_memoized[HashMap<u64, u64>, 0] 15 ns 143 ns -89.51%
WallTime iterative[0] 1 ns 3 ns -66.67%
WallTime from_elem_decimal[1024] 84 ns 203 ns -58.62%
WallTime from_elem[1024] 83 ns 167 ns -50.3%
WallTime rem 3 ns 6 ns -50%
Simulation permutations[5] 33.7 µs 66.1 µs -49.06%
Simulation from_elem_decimal[1024] 1.9 µs 3.1 µs -39.07%
WallTime mul 2 ns 3 ns -33.33%
Simulation from_elem[1024] 1.9 µs 2.8 µs -32.55%
WallTime find_highest_set_bit[65535] 5 ns 7 ns -28.57%
Simulation from_elem[2048] 3.4 µs 4.6 µs -25.87%
Simulation from_elem_decimal[2048] 3.4 µs 4.6 µs -25.87%
Simulation iterative[0] 119.2 ns 148.3 ns -19.66%
Simulation process_items_with_counter 865 ns 1,021.1 ns -15.29%
WallTime sort 120.2 µs 140.7 µs -14.6%
WallTime subset_sum[16] 4 µs 4.6 µs -12.34%
WallTime subset_sum[14] 2.1 µs 2.4 µs -12.25%
WallTime subset_sum[10] 1 µs 1.1 µs -12.02%
WallTime subset_sum[12] 1.9 µs 2.2 µs -11.96%
WallTime iterative[10] 16 ns 18 ns -11.11%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Ludea:getrandom (b79f040) with main (b30ce7d)

Open in CodSpeed

@GuillaumeLagrange GuillaumeLagrange merged commit b79f040 into CodSpeedHQ:main Jun 23, 2026
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants