Skip to content

perf(cdk/testing): reduce change detections when running parallel actions #21071

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

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

crisbeto
Copy link
Member

Switches all of our testing code to use parallel instead of Promise.all which reduces the number of change detections that we'll trigger during tests.

Also adds more type overloads to parallel, because the previous types didn't allow the values function to return mixed value arrays which we had in ~15 instances. I've tried to reduce the amount of code by only implementing up to 5 overloads, but we may want to expand it to 9 like Promise.all.

@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 17, 2020
@crisbeto crisbeto added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Nov 17, 2020
@crisbeto
Copy link
Member Author

crisbeto commented Nov 17, 2020

Caretaker note: these changes touch pretty much all test harnesses so it's possible that something could break during the presubmit. If something does break, I'll split this up into individual PRs.

@crisbeto crisbeto marked this pull request as ready for review November 17, 2020 20:03
@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release labels Nov 17, 2020
…ions

Switches all of our `testing` code to use `parallel` instead of `Promise.all` which reduces
the number of change detections that we'll trigger during tests.

Also adds more type overloads to `parallel`, because the previous types didn't allow
the `values` function to return mixed value arrays which we had in ~15 instances.
I've tried to reduce the amount of code by only implementing up to 5 overloads, but
we may want to expand it to 9 like `Promise.all`.
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

LGTM

* @param values A getter for the async values to resolve in parallel with batched change detection.
* @return The resolved values.
*/
export function parallel<T1, T2, T3, T4, T5>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh good catch, is there some way to do this without having a separate declaration for each number of params?

This is what I get for putting off actually using the function in our own tests 😞

Copy link
Member Author

Choose a reason for hiding this comment

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

There isn't. I took this from TS's built-in type for Promise.all and I've seen rxjs do something similar.

@mmalerba mmalerba added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Nov 19, 2020
@mmalerba
Copy link
Contributor

Changed to minor due to the new method signatures

@wagnermaciel wagnermaciel merged commit 4399757 into angular:master Nov 20, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants