Skip to content

bench: bound seed growth in random/base/* factory benchmarks - #15130

Draft
Planeshifter wants to merge 1 commit into
developfrom
claude/ecstatic-heisenberg-zw726w
Draft

bench: bound seed growth in random/base/* factory benchmarks#15130
Planeshifter wants to merge 1 commit into
developfrom
claude/ecstatic-heisenberg-zw726w

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • propagates the fix merged to develop in 448b573 to sibling packages.

This applies the same one-line fix already merged in 448b573 to the 38 random/base/* packages whose factory benchmark shares the identical opts.seed += i; accumulation. Left unbounded, the seed grows quadratically and overtakes mt19937's UINT32_MAX ceiling once the benchmark harness auto-scales past roughly 92k iterations, throwing a RangeError and failing the benchmark. Each fix mirrors the bounded form already used in that same file's array-seed benchmark (opts.seed[ 0 ] = i + 1;), matching what minstd, minstd-shuffle, and mt19937 already do.

Source commit: 448b573 ("bench: bound seed growth in factory benchmark"). Targets: all 38 packages under random/base/* with a factory benchmark carrying the accumulating form (arcsine, bernoulli, beta, betaprime, binomial, box-muller, cauchy, chi, chisquare, cosine, discrete-uniform, erlang, exponential, f, frechet, gamma, geometric, gumbel, hypergeometric, improved-ziggurat, invgamma, kumaraswamy, laplace, levy, logistic, lognormal, negative-binomial, normal, pareto-type1, poisson, randi, randn, randu, rayleigh, t, triangular, uniform, weibull).

Related Issues

Does this pull request have any related issues?

No related issues.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Validation performed before applying the change:

  • Pattern search scoped to lib/node_modules/@stdlib/random/** (the accumulating form occurs nowhere else in the repository); minstd, minstd-shuffle, and mt19937 already use the bounded form.
  • Two independent validation passes confirmed, per site, that the line sits in the identical structural position as the source fix and that each package funnels its seed option to the mt19937 factory's positive-integer/UINT32_MAX validation (directly, or via gamma/chisquare/poisson/improved-ziggurat/box-muller chains).
  • An adaptation pass confirmed each file contains exactly one occurrence with byte-identical surrounding context, so the source patch applies verbatim with no cascading edits; a style pass confirmed the replacement matches the merged form byte-for-byte.
  • Deliberately excluded: a second candidate pattern from the same 24-hour window (2740b02, removal of an unnecessary Boolean wrapper in lib/native.js) — all other textual matches wrap addons which return int32/uint32 values, where the wrapper is load-bearing, so no sites were propagated.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was authored by Claude Code as part of an automated fix-propagation routine; each target site was independently validated twice before the change was applied.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_011cVRuut4rg5J1R4WoiJgyP


Generated by Claude Code

Propagates fix from 448b573 ("bench: bound seed growth in `factory`
benchmark") to sibling packages with the same unbounded seed
accumulation in the `factory:seed=<integer>` benchmark.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011cVRuut4rg5J1R4WoiJgyP
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
random/base/arcsine $\\color{green}485/485$
$\\color{green}+100.00\\%$
$\\color{green}58/58$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}485/485$
$\\color{green}+100.00\\%$
random/base/bernoulli $\\color{green}391/391$
$\\color{green}+100.00\\%$
$\\color{green}49/49$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}391/391$
$\\color{green}+100.00\\%$
random/base/beta $\\color{red}874/885$
$\\color{green}+98.76\\%$
$\\color{red}119/120$
$\\color{green}+99.17\\%$
$\\color{green}16/16$
$\\color{green}+100.00\\%$
$\\color{red}874/885$
$\\color{green}+98.76\\%$
random/base/betaprime $\\color{green}458/458$
$\\color{green}+100.00\\%$
$\\color{green}47/47$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}458/458$
$\\color{green}+100.00\\%$
random/base/binomial $\\color{green}793/793$
$\\color{green}+100.00\\%$
$\\color{green}99/99$
$\\color{green}+100.00\\%$
$\\color{green}15/15$
$\\color{green}+100.00\\%$
$\\color{green}793/793$
$\\color{green}+100.00\\%$
random/base/box-muller $\\color{green}563/563$
$\\color{green}+100.00\\%$
$\\color{green}50/50$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}563/563$
$\\color{green}+100.00\\%$
random/base/cauchy $\\color{green}489/489$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}489/489$
$\\color{green}+100.00\\%$
random/base/chi $\\color{green}376/376$
$\\color{green}+100.00\\%$
$\\color{green}44/44$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}376/376$
$\\color{green}+100.00\\%$
random/base/chisquare $\\color{green}375/375$
$\\color{green}+100.00\\%$
$\\color{green}44/44$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}375/375$
$\\color{green}+100.00\\%$
random/base/cosine $\\color{green}490/490$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}490/490$
$\\color{green}+100.00\\%$
random/base/discrete-uniform $\\color{red}790/793$
$\\color{green}+99.62\\%$
$\\color{red}88/89$
$\\color{green}+98.88\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{red}790/793$
$\\color{green}+99.62\\%$
random/base/erlang $\\color{green}512/512$
$\\color{green}+100.00\\%$
$\\color{green}56/56$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}512/512$
$\\color{green}+100.00\\%$
random/base/exponential $\\color{green}420/420$
$\\color{green}+100.00\\%$
$\\color{green}46/46$
$\\color{green}+100.00\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{green}420/420$
$\\color{green}+100.00\\%$
random/base/f $\\color{green}490/490$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}490/490$
$\\color{green}+100.00\\%$
random/base/frechet $\\color{green}507/507$
$\\color{green}+100.00\\%$
$\\color{green}61/61$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}507/507$
$\\color{green}+100.00\\%$
random/base/gamma $\\color{green}623/623$
$\\color{green}+100.00\\%$
$\\color{green}93/93$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}623/623$
$\\color{green}+100.00\\%$
random/base/geometric $\\color{red}472/475$
$\\color{green}+99.37\\%$
$\\color{red}47/48$
$\\color{green}+97.92\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{red}472/475$
$\\color{green}+99.37\\%$
random/base/gumbel $\\color{green}493/493$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}493/493$
$\\color{green}+100.00\\%$
random/base/hypergeometric $\\color{red}639/643$
$\\color{green}+99.38\\%$
$\\color{red}70/71$
$\\color{green}+98.59\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{red}639/643$
$\\color{green}+99.38\\%$
random/base/improved-ziggurat $\\color{green}647/647$
$\\color{green}+100.00\\%$
$\\color{green}58/58$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}647/647$
$\\color{green}+100.00\\%$
random/base/invgamma $\\color{green}462/462$
$\\color{green}+100.00\\%$
$\\color{green}53/53$
$\\color{green}+100.00\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{green}462/462$
$\\color{green}+100.00\\%$
random/base/kumaraswamy $\\color{red}477/479$
$\\color{green}+99.58\\%$
$\\color{red}53/54$
$\\color{green}+98.15\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{red}477/479$
$\\color{green}+99.58\\%$
random/base/laplace $\\color{green}494/494$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}494/494$
$\\color{green}+100.00\\%$
random/base/levy $\\color{green}492/492$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}492/492$
$\\color{green}+100.00\\%$
random/base/logistic $\\color{green}493/493$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}493/493$
$\\color{green}+100.00\\%$
random/base/lognormal $\\color{green}497/497$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}497/497$
$\\color{green}+100.00\\%$
random/base/negative-binomial $\\color{green}534/534$
$\\color{green}+100.00\\%$
$\\color{green}89/89$
$\\color{green}+100.00\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{green}534/534$
$\\color{green}+100.00\\%$
random/base/normal $\\color{green}489/489$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}489/489$
$\\color{green}+100.00\\%$
random/base/pareto-type1 $\\color{green}499/499$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}499/499$
$\\color{green}+100.00\\%$
random/base/poisson $\\color{green}630/630$
$\\color{green}+100.00\\%$
$\\color{green}68/68$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}630/630$
$\\color{green}+100.00\\%$
random/base/randi $\\color{green}381/381$
$\\color{green}+100.00\\%$
$\\color{green}34/34$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}381/381$
$\\color{green}+100.00\\%$
random/base/randn $\\color{green}402/402$
$\\color{green}+100.00\\%$
$\\color{green}42/42$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}402/402$
$\\color{green}+100.00\\%$
random/base/randu $\\color{green}381/381$
$\\color{green}+100.00\\%$
$\\color{green}34/34$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}381/381$
$\\color{green}+100.00\\%$
random/base/rayleigh $\\color{green}430/430$
$\\color{green}+100.00\\%$
$\\color{green}46/46$
$\\color{green}+100.00\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{green}430/430$
$\\color{green}+100.00\\%$
random/base/t $\\color{green}478/478$
$\\color{green}+100.00\\%$
$\\color{green}77/77$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}478/478$
$\\color{green}+100.00\\%$
random/base/triangular $\\color{green}517/517$
$\\color{green}+100.00\\%$
$\\color{green}66/66$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}517/517$
$\\color{green}+100.00\\%$
random/base/uniform $\\color{green}485/485$
$\\color{green}+100.00\\%$
$\\color{green}58/58$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}485/485$
$\\color{green}+100.00\\%$
random/base/weibull $\\color{green}500/500$
$\\color{green}+100.00\\%$
$\\color{green}55/55$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}500/500$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

Copy link
Copy Markdown
Member Author

The Run affected tests failure (both the pull_request and push jobs on 84fe35d) is not a test failure and not caused by this PR's diff. The logs contain zero failing assertions: 848 test files ran and all passed. The job exits 123 because the very first test batch dies with:

make: bash: Argument list too long
make: *** [tools/make/lib/test/javascript.mk:318: test-javascript-files-min] Error 127

Mechanism: .github/workflows/scripts/run_affected_tests/run treats a benchmark-only edit as a package change, so this PR marks 38 random/base/* packages changed. Its dependent fan-out (grep for require( '@stdlib/random/base/<pkg>' )) then unions in a large fraction of the tree. The script batches the resulting test-file list via xargs sh -c 'make test-javascript-files-min FILES="$*"' _, but make expands the recipe into a single bash -c <string> argument; once a batch's FILES expansion pushes that string past the kernel's per-argument limit (MAX_ARG_STRLEN, ~128 KB), bash cannot be exec'd at all. xargs packs arguments up to its own total-size default, which exceeds the per-argument limit reachable through make, so the earliest (alphabetically first) batches — the ones containing the random/* tests — never ran. The failure is deterministic, so a re-run will not change the outcome; the benchmark fix itself is exercised by the Run affected benchmarks job.

Proposed patch for the runner script (out of scope for this propagation PR, so not included in the diff):

# .github/workflows/scripts/run_affected_tests/run
printf '%s\n' ${files} | xargs -s 100000 sh -c 'make test-javascript-files-min FILES="$*"' _

Bounding the total command line to ~100 KB keeps each FILES batch under MAX_ARG_STRLEN after make re-expands it (-n 500 would work as well). The same pattern exists in run_affected_benchmarks and run_affected_examples and warrants the same bound. Related: #92 reported the identical failure mode for make test locally.


Generated by Claude Code

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