test(@stdlib/random/base/mt19937): bound seed growth in factory benchmark - #15108
Draft
Planeshifter wants to merge 1 commit into
Draft
test(@stdlib/random/base/mt19937): bound seed growth in factory benchmark#15108Planeshifter wants to merge 1 commit into
factory benchmark#15108Planeshifter wants to merge 1 commit into
Conversation
…chmark The job `random_benchmarks` on workflow `random_benchmarks` failed on develop with `RangeError: invalid option. \`seed\` option must be a positive integer less than or equal to the maximum unsigned 32-bit integer. Option: \`4295022904\`.` in benchmark.factory.js. Root cause: the `factory:seed=<integer>` benchmark accumulated the seed across iterations (`opts.seed += i`), a triangular-number sum that deterministically exceeds the maximum unsigned 32-bit seed after roughly 92700 iterations, regardless of which SHA is checked out. This commit assigns a bounded, always-valid seed per iteration (`opts.seed = i + 1`), matching the pattern already used by the sibling `factory:seed=<array>` benchmark in the same file, so the benchmark no longer overflows the valid seed range. Ref: https://github.com/stdlib-js/stdlib/actions/runs/34173224406 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AiQ7xQp83BfogoNxDNvNW8
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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.
Resolves #{{TODO: add issue number}}.
Description
This pull request:
factory:seed=<integer>benchmark in@stdlib/random/base/mt19937so it no longer crashes the nightlyrandom_benchmarksjob.Failing run: https://github.com/stdlib-js/stdlib/actions/runs/34173224406 (
random_benchmarks, develop).Symptom:
RangeError: invalid option.seedoption must be a positive integer less than or equal to the maximum unsigned 32-bit integer. Option:4295022904.thrown frombenchmark.factory.js, aborting the job.Root cause: the
factory:seed=<integer>benchmark accumulates the seed across iterations (opts.seed += i). That is a triangular-number sum (1 + Σi), which deterministically exceedsUINT32_MAX(4294967295) once the loop passes roughly 92700 iterations — reproduced locally, and it throws at the exact seed value (4295022904) reported in the failing run. This is unrelated to any specificdevelopcommit; it reproduces on every SHA once the benchmark harness's iteration count crosses that threshold, which is why it fails on schedule rather than on a particular push.Fix: assign a bounded, always-valid seed per iteration (
opts.seed = i + 1) instead of accumulating. This matches the pattern already used by the siblingfactory:seed=<array>benchmark two blocks below in the same file (opts.seed[ 0 ] = i + 1;), so the change is a one-line, in-idiom fix rather than a new approach.Related Issues
No.
Questions
No.
Other
Validation:
@stdlib/random/base/mt19937'sfactory: it throws ati = 92682,seed = 4295022904— the exact value from the failing run.make lint-javascript-benchmarks) was not runnable in this sandbox (no top-levelnode_modulesinstalled); the diff is a single line that mirrors the existing sibling benchmark's exact style in the same file, so no formatting/lint drift is expected.factory/mainimplementation, tests, or docs), and style/conventions (confirmed the replacement matches the siblingseed=<array>benchmark's idiom and existing indentation exactly). All three approved with no blocking findings.Reviewer notes (non-blocking):
opts.seed += i;) exists in the same-named benchmark across roughly 40 sibling@stdlib/random/base/*packages (e.g.beta,uniform,normal,minstd-shuffle, ...). None of those failed in this observation window, but each will hit the same overflow once its own benchmark run crosses ~92700 iterations. Fixing all of them is out of scope for this CI-failure fix (would cascade well beyond the reported failure); worth a dedicated follow-up sweep.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of an automated CI-failure investigation and fix routine; the failure was reproduced locally against the actual
mt19937factory before and after the change, and the fix was independently reviewed by three automated reviewer passes before submission.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01AiQ7xQp83BfogoNxDNvNW8
Generated by Claude Code