Repository navigation
feat: disable ASLR for walltime/memory and seed Go's global math/rand - #596
Draft
not-matthias wants to merge 2 commits into
Draft
not-matthias wants to merge 2 commits into
not-matthias wants to merge 2 commits into
Conversation
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
Merging this PR will not alter performance2 warnings
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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