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

Try to automatically set maxWorkers correctly #23

Open
blimmer opened this issue Aug 16, 2023 · 0 comments
Open

Try to automatically set maxWorkers correctly #23

blimmer opened this issue Aug 16, 2023 · 0 comments

Comments

@blimmer
Copy link
Owner

blimmer commented Aug 16, 2023

Background

Jest uses os.availableParallelism() and os.cpus().length to figure out how many Jest workers to spawn. However, on CircleCI Docker executors, these function calls return invalid results.

For example, on my medium+ executor with 3 vCPU cores:

circleci@00740471180a:~$ node
Welcome to Node.js v18.16.0.
Type ".help" for more information.
> const os = require('os')
undefined
> os.availableParallelism()
36
> os.cpus().length
36

This causes frequent OOM errors and crashes, which are hard for the average user to debug. There are several feature requests to CircleCI to make this better:

However, I'm not holding my breath on them fixing this on their end.

Possible Solution

It looks like using this snippet reports the correct number of vCPUs available:

circleci@2866814cd4c3:/tmp$ echo $(($(cat /sys/fs/cgroup/cpu/cpu.shares) / 1024))
3

So, it would be great to automatically set maxWorkers via this, instead of the inaccurate defaults used by jest.

Notes

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

No branches or pull requests

1 participant