Repository navigation
feat: disable ASLR for walltime/memory and seed Go's global math/rand - #596
not-matthias wants to merge 2 commits into
Conversation
Merging this PR will not alter performance2 warnings
Comparing Footnotes
|
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
Simulation already runs under setarch --addr-no-randomize. Walltime and memory kept ASLR on, so the memory layout and address-seeded hashes (e.g. abseil's absl::Hash) changed on every run and added variance. Wrap the innermost benchmark command in setarch for both modes. The kernel clears ADDR_NO_RANDOMIZE when exec'ing setuid or file-capability binaries, so setarch sits inside sudo/systemd-run for walltime and inside the shell command that memtrack runs for memory mode. setarch is probed once. When it fails, e.g. because Docker's default seccomp profile blocks personality(ADDR_NO_RANDOMIZE), the runner warns and runs the benchmark unchanged instead of failing. The probe is skipped off Linux. Refs COD-4013
8c12824 to
f257c81
Compare
[Medium impact] The changes reach benchmark runs across several measurement modes. The PR appears safe to merge, with a non-blocking gap in tests for the new ASLR behavior.
|
f257c81 to
a20700e
Compare
Summary
Reduce run-to-run variance from random seeds the runner doesn't control.
setarch --addr-no-randomize. Walltime and memory now do too, so the memory layout and address-seeded hashes (e.g. abseil'sabsl::Hash) stay the same across runs.setarchwraps the innermost benchmark command, because the kernel clearsADDR_NO_RANDOMIZEwhen exec'ing setuid or file-capability binaries (sudo,memtrack).setarchis probed once. If it fails (e.g. Docker's default seccomp profile), the runner warns and runs the benchmark unchanged.GODEBUG=randautoseed=0in every mode. The globalmath/randstarts fromSeed(1). The value is prepended to the user'sGODEBUG, so their settings are kept and an explicitrandautoseedstill wins.Testing
cargo clippy --all-targets, executor and runner-shared tests pass.0x40000andGODEBUG=randautoseed=0,<user value>.Open
Fixes COD-4013