-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Set max old space size on coverage and test #5382
Set max old space size on coverage and test #5382
Conversation
|
From the docs:
I'm not sure what swapping refers to, but I'm worried setting it to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- why 4096 and not more ? In the past (before the hardhat migration to EDR 4096 was not enough)
- why only on coverage and not on test ?
I'm testing on multiple machines (including CI) to see what we need. Ideally it would be below 8192 so that 8gb machines could run coverage. The test run requires significantly less memory to the point that the default is generally sufficient. We could set it to something like 4096 to just be safe though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really not a big fan of this change:
- It fixes a value that may be to-much to to little depending on the evolution of the tests and tooling. Hardhat evolution did lower the needed value in the past. Same is true of coverage. Also, as we add more tests this could become outdated
- Different machines (hardware, os) will have different things available.
If our estimation is too tight, there is a risk we have to update it to frequently. If the estimation is not tight enough, it will some "small" machines
IMO this value should be controlled by the host of the machine. Not by us. And an issue with what this PR proposes is that it doesn't allow the machine's host to override the value we fix without editing the package.json.
package.json
Outdated
@@ -25,7 +25,7 @@ | |||
"prepack": "scripts/prepack.sh", | |||
"generate": "scripts/generate/run.js", | |||
"version": "scripts/release/version.sh", | |||
"test": "hardhat test", | |||
"test": "NODE_OPTIONS=\"--max-old-space-size=8192\" hardhat test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove that from the tests?
My understanding is that it was only really needed for the coverage ... and we now have an elegant integration in coverage.sh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on the current state?
.github/workflows/checks.yml
Outdated
env: | ||
NODE_OPTIONS: --max_old_space_size=8192 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep this as the CI config. If this is ever modified, the script would not override it.
scripts/checks/coverage.sh
Outdated
if [[ $NODE_OPTIONS != *"--max-old-space-size"* ]]; then | ||
export NODE_OPTIONS="${NODE_OPTIONS} --max-old-space-size=8192" | ||
fi | ||
eval "scripts/set-max-old-space-size.sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need an eval here ?
eval "scripts/set-max-old-space-size.sh" | |
scripts/set-max-old-space-size.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was already updated. The line is now
. ./scripts/set-max-old-space-size.sh
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
Fixes #5363
Hardhat has a known issue which results in
JavaScript heap out of memory
error unless the max old space size is set. This PR will automatically set it on required scripts (test and coverage).Note: this fix only sets the
NODE_OPTIONS
max-old-space-size
flag if it was not set already. Additional options inNODE_OPTIONS
are maintained. The new flag is not maintained after the call is completed.PR Checklist
npx changeset add
)