rand_xoshiro: Shrink all-zero-seed fallback via shared rodata constant#111
Merged
Conversation
Replace the per-RNG `SplitMix64::seed_from_u64(0)` cold call with a single 64-byte `ZERO_SEED_FALLBACK` static. Reduces combined `.text + .rodata` by 496 B on a small binary that exercises every `from_seed`, and shrinks each call site by 8 B. The all-zero-seed output is byte-identical to the previous behavior; a new `zero_seed_fallback_matches_splitmix` test derives the static at runtime and asserts equality, and each RNG has a new `zero_seed_maps_to_seed_from_u64_zero` test pinning the remap. Removing the check entirely would save 51 B at the call site, and 592 B in `.text + .rodata` (see #107).
dhardy
reviewed
May 14, 2026
dhardy
approved these changes
May 16, 2026
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.
Replace the per-RNG
SplitMix64::seed_from_u64(0)cold call with a single 64-byteZERO_SEED_FALLBACKstatic.Reduces combined
.text + .rodataby 496 B on a small binary that exercises everyfrom_seed, and shrinks each call site by 8 B. The all-zero-seed output is byte-identical to the previous behavior; a newzero_seed_fallback_matches_splitmixtest derives the static at runtime and asserts equality, and each RNG has a newzero_seed_maps_to_seed_from_u64_zerotest pinning the remap.Removing the check entirely would save 51 B at the call site, and 592 B in
.text + .rodata(see #107).