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

[FEATURE] Configurable thread limit #1184

Open
patrickhousley opened this issue Sep 20, 2024 · 2 comments
Open

[FEATURE] Configurable thread limit #1184

patrickhousley opened this issue Sep 20, 2024 · 2 comments

Comments

@patrickhousley
Copy link

Is your feature request related to a problem? Please describe.
Not really an issue but clicking the "run all" button in a mono-repo with 200+ packages or configuring auto-run can peg CPU to a point that it can cause machine instability. Even just running the process to get the list of test files when vscode is opened can cause issues.

Describe the solution you'd like
Can we add a configuration option to limit the number of parallel threads or possibly limit the number of child processes spawned in parallel to the number of CPU cores?

@connectdotz
Copy link
Collaborator

Hi,

How is your monorepo set up? If you have only one workspace folder, you can use Jest's configuration (such as maxWorkers) to limit the parallel threads. However, if you have multiple workspace folders (multi-root workspace) or are using jest.virtualFolders, then, currently, each eligible folder will spawn its own Jest process. In this case, using such configuration options can help limit resource consumption.

@patrickhousley
Copy link
Author

This is a large Nx workspace with 200+ apps/libs. I started with trying to setup each app/lib in jest.virtualFolders but that ended up slowing down vscode, my computer, etc and listing every project in the footer bar pushed all other useful info down there off the screen. Right now I am using:

  "jest.outputConfig": "test-results-based",
  "jest.runMode": "on-demand",
  "jest.jestCommandLine": "npm run jest -- --config ./jest.config.ts",

This takes care of most of the annoyances and is probably the right way to configure such a large mono-repo. I figured the plugin could be improved to use some form of a thread/process pool for virtual folders. Even on smaller mono-repos it might be nice to be able to limit the number of parallel running jest instances. Just a thought, feel free to close if you are not amicable to the idea.

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

No branches or pull requests

2 participants