-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Limit concurrency to 2 in a CI environment and 8 otherwise #1551
Limit concurrency to 2 in a CI environment and 8 otherwise #1551
Conversation
Relevant Travis issue: travis-ci/travis-ci#4696 I think we should only cap it to |
So maybe 2 on CI? That way we don't hold everything up for one slow test file. Even one CPU should be fine swapping between two threads. And when not on a CI I'd say go even further. Maybe cap at 8. Majority of the time if this is run locally it'll be on bare metal so Although we'll encounter the same issue on local machines if you're running your tests in docker. But then users are less likely to have a large number of threads (most likely 4 - 8) so that's unlikely to cause issues. Alternatively, as this seems mostly related to Docker, we could set the limits with an |
Alright, so let's cap it at 2 for CI and 8 for normal. @novemberborn Thoughts? |
Done, can be rewritten as let concurrency = Math.min(os.cpus().length, process.env.CI ? 2 : 8); but thought maybe that's too much for one line? |
684b8d9
to
a7d44c0
Compare
api.js
Outdated
Math.min(concurrency, 2); | ||
} else { | ||
Math.min(concurrency, 8); | ||
} |
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.
You're not assigning this to anything.
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.
Woops, sorry running on 2 hours sleep 😬
It looks fine. That's how I would have written it. |
Can you also mention the capping behavior in the readme? |
78674d0
to
35298f9
Compare
Yeah, done. Also in the docs:
Technically this should be threads not cores. Do you want me to change that? |
No, it's CPU cores:
|
Node.js docs are misleading, it's definitely threads:
|
I see. Alright, update it to threads. |
Node.js issue: nodejs/node#16279 |
Let's go with |
Good idea, done 👍 |
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.
👍 on the CI change, but I don't understand why we'd need to cap this at all for non-CI?
For cases where Docker is used locally since it reports the incorrect count. And, from experience, anything more than 4-5 doesn't improve the performance. But yes, it's pretty arbitrary, so not sure whether it makes sense. |
@novemberborn Just to clarify, it only caps the default from But yeah, like I mentioned in an above comment, it's unlikely to cause issues locally unless they have a really high thread count.
|
@lukechilds @sindresorhus OK, I'm still leaning towards not capping this outside of a CI environment. Just seems like unnecessary logic. |
Ok, let's drop it. We can add it back if it's an actual proven problem. |
@lukechilds I've taken the liberty to push these changes. Now also using |
@novemberborn was not aware of |
Thanks @lukechilds! |
The new default of using CPU cores for concurrency works well most of the time, however when running tests in Docker (Travis) it will use the CPU count of the host machine, not what's been allotted to the container.
Discovered when the Got tests where timing out for no apparent reason. I ran
os.cpus().length
on the container and it returned 32. Capping at 4 resolved the issue.This PR changes AVA to use whichever is lower out of
os.cpus().length
or4
for concurrency by default. This seems like a sensible soft limit. You can still manually specify a concurrency that is larger than 4.