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

Controlling memory usage of node-haste when loading tests #535

Closed
jeremiahrhall opened this issue Oct 6, 2015 · 10 comments
Closed

Controlling memory usage of node-haste when loading tests #535

jeremiahrhall opened this issue Oct 6, 2015 · 10 comments

Comments

@jeremiahrhall
Copy link

I have an app that is built in CircleCI, which has a 4GB memory limit that terminates the build when the threshold is exceeded.

My build hits this threshold when Jest runs. According to the output from CircleCI, there are 32 processes open at the time running node-haste/lib/analyze-changed.js, cumulatively using about 3.5GB of memory. Add in the Jest process which uses around 350mb and some OS overhead and I'm over.

Jest has the -w option but, node-haste's maxProcesses option is set to os.cpus().length in HasteModuleLoader.

Can this be made configurable?

@jeremiahrhall
Copy link
Author

Here's a minimal implementation: master...jeremiahrhall:dev/node-haste-max-processes-arg

@cpojer
Copy link
Member

cpojer commented Oct 6, 2015

We already have a maxWorkers option that should take care of this, no? It is passed on to the TestRunner.

@jeremiahrhall
Copy link
Author

The HasteModuleLoader isn't actually passed that option right now. In fact, TestRunner does not pass the second options param to the loader.

@jeremiahrhall
Copy link
Author

I ended up changing my code to use the maxWorkers option but, it still needed to be passed through to the module loader: master...jeremiahrhall:dev/node-haste-max-workers-arg

@cpojer
Copy link
Member

cpojer commented Oct 6, 2015

That's weird. Feel free to send a Pull Request :)

@jeremiahrhall
Copy link
Author

👍

@chriddyp
Copy link

@jeremiahrhall - did you have any luck in reducing the memory usage besides limiting maxWorkers? I've gone over Circle CI's 4GB of RAM with 4 workers. Reducing to 3 workers seems to lower the memory enough to not cause circleci to crash (died unexpectedly).

@cpojer
Copy link
Member

cpojer commented Jan 13, 2016

Also check out #599, which replaces node-haste with an entirely new implementation.

@jeremiahrhall
Copy link
Author

I only tried setting maxWorkers to 4 and that dropped memory usage to well below 4GB for me.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants