Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Yarn workspace foreach is considerably slower compared to other alternatives #3562

Closed
1 task
pastelsky opened this issue Oct 12, 2021 · 3 comments
Closed
1 task
Labels
bug Something isn't working

Comments

@pastelsky
Copy link

pastelsky commented Oct 12, 2021

Self-service

  • I'd be willing to implement a fix

Describe the bug

I have a yarn workspace with around 20 packages. When I run a simple echo test —

"scripts": {
    "echo-test": "yarn workspaces foreach -v --parallel exec echo 'hi'",
}

It takes 14-15 seconds for echo to execute. I have 6 physical cores.

This is a lot compared to me running this directly through bash, or using other utilities like —
https://www.npmjs.com/package/workspaces-run

which take under 1 second here.

To reproduce

Unfortunately, I wasn't able to create a minimal repro for this. If I try to emulate the same workspace structure in a fresh project, I am not able to achieve the same high command execution times for yarn workspace foreach exec.

I did notice however, that increasing parallelism makes the performance worse. For example, on increasing this to parallel of 40, it takes 18+ seconds to execute.

I also noticed that when I run this, a node process with 150% CPU usage throughout the lifetime of the run appears.
This is strange, because the executed command itself isn't CPU intensive at all.

Environment

System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.17.4 - /private/var/folders/_j/128s9ngn26v2z9sx5c28bdd00000gn/T/xfs-38cb4655/node
    Yarn: 3.1.0-rc.8 - /private/var/folders/_j/128s9ngn26v2z9sx5c28bdd00000gn/T/xfs-38cb4655/yarn
    npm: 7.21.1 - ~/.nvm/versions/node/v14.17.4/bin/npm
  npmPackages:
    jest: ^26.6.3 => 26.6.3

Additional context

No response

@pastelsky pastelsky added the bug Something isn't working label Oct 12, 2021
@pastelsky pastelsky changed the title [Bug]: Yarn workspace foreach is considerably slow compared to other alternatives [Bug]: Yarn workspace foreach is considerably slower compared to other alternatives Oct 12, 2021
@merceyz
Copy link
Member

merceyz commented Oct 12, 2021

Duplicate of #2575

@merceyz merceyz marked this as a duplicate of #2575 Oct 12, 2021
@merceyz merceyz closed this as completed Oct 12, 2021
@merceyz
Copy link
Member

merceyz commented Oct 12, 2021

While this issue mentions exec it's the same problem as #2575

@pastelsky
Copy link
Author

@merceyz would that explain why it's only one node process that shoots up in CPU usage to 150%?
If this were #2575 , isn't it expected that the performance cost is paid by each newly spawned process instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants