-
Notifications
You must be signed in to change notification settings - Fork 29.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
test_runner: fix test runner concurrency #47675
Conversation
CC @nodejs/performance Who can help me with creating a benchmark? I never have before |
Is this the relevant invocation? node/lib/internal/test_runner/runner.js Lines 390 to 397 in 0c5f253
If it is expected that test files are executed in parallel, then that should be covered by a test before any benchmark. Benchmarks are good for performance comparisons, but this is about a difference between design and implementation, i.e., functional correctness. |
yes
I will add a test |
@aduh95 In #45175, was the main motivation behind |
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.
Is the number of concurrent tests guaranteed to be at least two? I thought it depended on os.availableParallelism()
, in which case it looks like this test might fail when only one or two CPU cores are assigned to the process group.
this fix introduced a race condition in tests outputs being reported out of order, so I fixed that as well |
@@ -62,3 +69,14 @@ describe( | |||
it('should run after other suites', expectedTestTree); | |||
}); | |||
} | |||
|
|||
test('--test multiple files', { skip: os.availableParallelism() < 3 }, async () => { |
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.
@cjihrig please confirm this skip makes sense
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 think it makes sense. I think you could verify by replacing the use of os.availableParallelism()
in the test runner code with 1 or 2 and seeing if the test hangs.
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.
lgtm
e1dbbd2
to
bbc6eaf
Compare
@benjamingr @mcollina PTAL |
lib/internal/test_runner/runner.js
Outdated
@@ -237,22 +233,36 @@ class FileTest extends Test { | |||
break; | |||
} | |||
} | |||
#accumelateReportItem({ kind, node, comments, nesting = 0 }) { |
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.
The logic in this function (and even the function signature) seems like it should be part of #handleReportItem()
. Is it possible to handle this there?
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.
handleReportItem
happens only in order of reporting (using this.isClearToSend()
), however, #skipReporting
returns wrong values if it is called after the child process has completed but the test has not yet been reported
bbc6eaf
to
17e3338
Compare
Landed in 8becacb...dccd25e |
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#47675 Fixes: nodejs#47365 Fixes: nodejs#47696 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fixes: #47365
Fixes: #47696
SafePromiseAllSettledReturnVoid
runs sequentially before this fix :(this makes me wonder if we should add a benchmark for the test runner