Skip to content

Conversation

@ethanburrelldd
Copy link
Owner

@ethanburrelldd ethanburrelldd commented Sep 11, 2025

Summary

Fixes concurrency bug where weighted operations could exceed the specified parallelism limit.

Details

In the current implementation with maxConcurrency = 8 and concurrentUnitsInProgress = 4, a task with weight = 8 could be queued due to no check existing to prevent queueing this new task. This change waits for enough free units before queueing the weight-8 task.

This oversubscription causes test flakes and slower execution due to too many tasks running simultaneously.

Changes:

  • Added concurrency check before starting new weighted tasks
  • Introduced iterator caching to resume processing when capacity becomes available
  • Allow zero-weight tasks to run alongside full-capacity operations
  • Updated test expectations to reflect correct behavior

How it was tested

  • integration testing by patching the library in production repo
  • testing in rush-redis-cobuild-plugin-integration-test
  • unit tests

Impacted documentation

let concurrentUnitsInProgress: number = 0;

const iterator: Iterator<TEntry> | AsyncIterator<TEntry> = (iterable as AsyncIterable<TEntry>)[
const baseIterator: Iterator<TEntry> | AsyncIterator<TEntry> = (iterable as AsyncIterable<TEntry>)[
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: does this need to be of type Iterator<TEntry> | AsyncIterator<TEntry>? it looks like iterable is of type AsyncIterable<TEntry>,?

Can we simplify so we only have to contain types for AsyncIterator?

expect(fn).toHaveBeenNthCalledWith(3, 3, 2);
});

it('returns the same result as built-in Promise.all', async () => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated test case

@ethanburrelldd ethanburrelldd changed the title fix weighted concurrency scheduling to prevent oversubscription [node-core-library] Fix weighted oversubscription in forEachAsync Sep 11, 2025
Copilot AI and others added 14 commits September 16, 2025 16:44
…ID (microsoft#5364)

* Initial plan

* Replace uuid package with Node.js built-in crypto.randomUUID

Co-authored-by: bmiddha <5100938+bmiddha@users.noreply.github.com>

* Add rush change file for uuid package replacement

Co-authored-by: bmiddha <5100938+bmiddha@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bmiddha <5100938+bmiddha@users.noreply.github.com>
…soft#5363)

* Add edge case for projects with duplicate names

* Replace custom interfaces with official PNPM types; temporarily remove the V6 kludge

* Add lockfilePath.ts utility that can completely eliminate `@lifaon/path`

* Completed rewrite of 5.4 loader logic

* Remove "@lifaon/path" dependency

* Splite createLockfileEntry() into createProjectLockfileEntry() and createPackageLockfileEntry()

* Upgrade to use @pnpm/lockfile.types@1002.0.1

* Implement support for lockfile version 6.0

* Hide the "." package from Rush workspaces, shuffling the jsonId's in all the snapshots

* Fix an incorrect path

* rush change

* Improve formatting of 6.0 suffixes

* Move entry to nonbrowser-approved-packages.json

* Add a failing test case for "link:" in packages section

* PR feedback

* PR feedback: don't try to resolve "link:" under packages section

* rush update
Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
* [rush-serve] Add dependencies to operations, support abort

* Adjust "silent" field in socket

---------

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
…ighlighter (microsoft#5366)

* Enable syntax highlighting for pnpmfile.cjs tab

* Highlight package.json as well

* Introduce PnpmfileRunner.ts to isolate .pnpmfile.cjs execution

* rush change

* Disable webpack bundle size limits, since this app is served from localhost

* In a Rush repo, the ".pnpmfile.cjs" tab should show Rush's file, not the generated temp file

* Upgrade Prettier to support `async using`

* prettier -w .

* PR feedback: use "await using"

* PR feedback

* PR feedback

* rush change

* PR feedback

* Fix build break

* Revert `[Symbol.asyncDispose]()` because it isn't supported by Node 18
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.

5 participants