Skip to content

Conversation

@shiavm006
Copy link
Contributor

Description

What is the purpose of this pull request?

This pull request:

fixes a deadlock bug in @stdlib/utils/parallel where the function would hang indefinitely on single-core systems (numCPUs = 1) because defaults would set workers = 0. a deadlock bug when called with empty arrays (parallel([])) where clamping logic would reduce workers to 0.
fixes a deadlock bug when explicitly passing {workers: 0, concurrency: 0} options and updated defaults.js to use @stdlib/math/base/special/fast/max to ensure minimum of 1 worker/concurrency as suggested by maintainer ,adds safeguard in main.js to prevent workers/concurrency from dropping below 1 after clamping logic , tests covering all three edge cases.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • No related issue (discussed with maintainer @kgryte via direct message)

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.

This fix was discussed with maintainer @kgryte who suggested using @stdlib/math/base/special/fast/max for the defaults.js fix. The safeguard in main.js was added to handle edge cases where clamping could still result in 0 workers even with the defaults fix.

Checklist

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

  • Read, understood, and followed the [contributing guidelines][contributing].

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.".

N/A


@stdlib-js/reviewers
[contributing]: https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 7, 2026
Empty arrays are rejected by validation before the safeguard runs, so this test case is invalid. The safeguard still protects against single-core systems and explicit zero values.
@shiavm006
Copy link
Contributor Author

cc @kgryte i verified it locally ya u can check it out like can disscuss on changes and implement that same

@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
utils/parallel $\color{red}1366/1370$
$\color{green}+99.71%$
$\color{red}150/152$
$\color{green}+98.68%$
$\color{green}35/35$
$\color{green}+100.00%$
$\color{red}1366/1370$
$\color{green}+99.71%$

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants