Skip to content

test_runner: fix test runner concurrency - #47675

Closed
MoLow wants to merge 2 commits into
nodejs:mainfrom
MoLow:fix-test-runner-concurrency
Closed

test_runner: fix test runner concurrency#47675
MoLow wants to merge 2 commits into
nodejs:mainfrom
MoLow:fix-test-runner-concurrency

Conversation

@MoLow

@MoLowMoLow commented Apr 22, 2023

Copy link
Copy Markdown
Member

Fixes: #47365
Fixes: #47696

SafePromiseAllSettledReturnVoid runs sequentially before this fix :(
this makes me wonder if we should add a benchmark for the test runner

@MoLow
MoLow requested a review from aduh95April 22, 2023 20:43
@nodejs-github-botnodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 22, 2023
@MoLow

Copy link
Copy Markdown
MemberAuthor

CC @nodejs/performance Who can help me with creating a benchmark? I never have before

@MoLowMoLow added performance Issues and PRs related to the performance of Node.js. test_runner Issues and PRs related to the test runner subsystem. labels Apr 22, 2023
@tniessen

Copy link
Copy Markdown
Member

SafePromiseAllSettledReturnVoid runs sequentially before this fix

Is this the relevant invocation?

construnFiles=()=>{
root.harness.bootstrapComplete=true;
returnSafePromiseAllSettledReturnVoid(testFiles,(path)=>{
constsubtest=runTestFile(path,root,inspectPort,filesWatcher);
runningSubtests.set(path,subtest);
returnsubtest;
});
};

this makes me wonder if we should add a benchmark for the test runner

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.

@MoLow

Copy link
Copy Markdown
MemberAuthor

Is this the relevant invocation?

yes

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.

I will add a test

@tniessen

Copy link
Copy Markdown
Member

@aduh95 In #45175, was the main motivation behind SafePromiseAllSettledReturnVoid not having to allocate an array for results, and so that the caller automatically obtains a Promise<void>? If so, this appears to be the only call site, so maybe we can just use SafePromiseAllSettled instead and return the Promise<void> from the test runner instead?

@tniessentniessen left a comment

Copy link
Copy Markdown
Member

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.

@MoLowMoLow added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Apr 22, 2023
@MoLow

Copy link
Copy Markdown
MemberAuthor

this fix introduced a race condition in tests outputs being reported out of order, so I fixed that as well

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
Contributor

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.

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@MoLowMoLow added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Apr 23, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@MoLow
MoLowforce-pushed the fix-test-runner-concurrency branch from e1dbbd2 to bbc6eafCompareApril 24, 2023 18:26
@MoLow

Copy link
Copy Markdown
MemberAuthor

@cjihrig can you take a look? I've had to fix multiple race conditions in the test runner.
this also depends on #47699 to accurately count tests

@MoLow

Copy link
Copy Markdown
MemberAuthor

@benjamingr@mcollina PTAL

@MoLowMoLow added commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. and removed commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Apr 24, 2023
Comment threadlib/internal/test_runner/tests_stream.js Outdated
Comment threadlib/internal/test_runner/runner.js Outdated
Comment threadlib/internal/test_runner/runner.js Outdated
Comment threadlib/internal/test_runner/runner.js Outdated

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
MemberAuthor

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

@MoLow
MoLowforce-pushed the fix-test-runner-concurrency branch from bbc6eaf to 17e3338CompareApril 24, 2023 19:25
@MoLowMoLow mentioned this pull request Apr 24, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@MoLow

Copy link
Copy Markdown
MemberAuthor

@MoLowMoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 24, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 24, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 8becacb...dccd25e

nodejs-github-bot pushed a commit that referenced this pull request Apr 24, 2023
PR-URL: #47675Fixes: #47365Fixes: #47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
nodejs-github-bot pushed a commit that referenced this pull request Apr 24, 2023
PR-URL: #47675Fixes: #47365Fixes: #47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@MoLow
MoLow deleted the fix-test-runner-concurrency branch April 24, 2023 22:33
@tniessentniessen mentioned this pull request Apr 26, 2023
targos pushed a commit that referenced this pull request May 2, 2023
PR-URL: #47675Fixes: #47365Fixes: #47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
targos pushed a commit that referenced this pull request May 2, 2023
PR-URL: #47675Fixes: #47365Fixes: #47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@targostargos mentioned this pull request May 2, 2023
danielleadams pushed a commit that referenced this pull request Jul 6, 2023
PR-URL: #47675Fixes: #47365Fixes: #47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
danielleadams pushed a commit that referenced this pull request Jul 6, 2023
PR-URL: #47675Fixes: #47365Fixes: #47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MoLow added a commit to MoLow/node that referenced this pull request Jul 6, 2023
PR-URL: nodejs#47675Fixes: nodejs#47365Fixes: nodejs#47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MoLow added a commit to MoLow/node that referenced this pull request Jul 6, 2023
PR-URL: nodejs#47675Fixes: nodejs#47365Fixes: nodejs#47696
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.commit-queue-rebaseAdd this label to allow the Commit Queue to land a PR in several commits.needs-ciPRs that need a full CI run.performanceIssues and PRs related to the performance of Node.js.test_runnerIssues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nested test counting is wrong concurrent tests are slow

6 participants

@MoLow@tniessen@nodejs-github-bot@mcollina@benjamingr@cjihrig