Skip to content

feat: seed Go's global math/rand deterministically - #596

Merged
not-matthias merged 1 commit into
mainfrom
cod-4013-disable-aslr-in-walltimememory-and-fix-go-mathrand-seed-in
Oct 30, 2026
Merged

not-matthias merged 1 commit into
mainfrom
cod-4013-disable-aslr-in-walltimememory-and-fix-go-mathrand-seed-in

Conversation

@not-matthias

@not-matthias not-matthias commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

TLDR: Go benchmarks that draw from the global math/rand got a random seed on every run. The runner now sets GODEBUG=randautoseed=0 in every mode, so it starts from Seed(1).

  • randautoseed=0 is put in front of the user's GODEBUG. Go uses the last value for each setting, so the user's settings stay and an explicit randautoseed from the user still wins.
  • ASLR in walltime and memory mode is not changed.

Refs COD-4013

@codspeed

codspeed Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 8 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 41 untouched benchmarks
⏩ 6 skipped benchmarks1


Comparing cod-4013-disable-aslr-in-walltimememory-and-fix-go-mathrand-seed-in (fe3c0c6) with main (d14d95d)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@not-matthias
not-matthias marked this pull request as ready for review October 29, 2026 17:37
Set GODEBUG=randautoseed=0 on benchmark processes in every mode, so the
global math/rand source starts from Seed(1) instead of a random seed and
code that draws from it behaves the same on every run.

The setting is prepended to the user's GODEBUG. Go uses the last
occurrence of a setting, so the user's other settings are kept and an
explicit randautoseed from the user still wins.

Refs COD-4013
@not-matthias
not-matthias force-pushed the cod-4013-disable-aslr-in-walltimememory-and-fix-go-mathrand-seed-in branch from 8c12824 to f257c81 Compare October 29, 2026 17:38
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

The runner now adds GODEBUG=randautoseed=0 in every measurement mode.

  • Go benchmarks start with the same global random sequence by default.

Reviews (2) · Last reviewed commit: "feat: seed Go's global math/rand determi..." · Reviewed by Greptile

Comment thread src/executor/helpers/aslr.rs Resolved
@not-matthias
not-matthias force-pushed the cod-4013-disable-aslr-in-walltimememory-and-fix-go-mathrand-seed-in branch from f257c81 to a20700e Compare October 29, 2026 17:44
@not-matthias
not-matthias force-pushed the cod-4013-disable-aslr-in-walltimememory-and-fix-go-mathrand-seed-in branch from a20700e to fe3c0c6 Compare October 30, 2026 13:25
@not-matthias not-matthias changed the title feat: disable ASLR for walltime/memory and seed Go's global math/rand feat: seed Go's global math/rand deterministically Oct 30, 2026
@not-matthias
not-matthias requested a review from lvaroqui October 30, 2026 13:26

@GuillaumeLagrange GuillaumeLagrange left a comment

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.

lgtm

@not-matthias
not-matthias merged commit ea54386 into main Oct 30, 2026
66 checks passed
@not-matthias
not-matthias deleted the cod-4013-disable-aslr-in-walltimememory-and-fix-go-mathrand-seed-in branch October 30, 2026 14:53
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