Repository navigation
perf(ripple): optimize event registration - #18633
Merged
Merged
Conversation
Improve scalabiliity of Angular Material components. When used in an app with a large and heavy UI with large numbers of material components (for example in table cells), they can quickly become prohibitively expensive due to their heavy DOM structure and lots of up-front work. Each component with a ripple ends up registering 6 event listeners. This PR makes 4 of them registered on-demand. Note, that this is really a stop-gap solution to help improve performance in our application. A proper implementation should utilize a single document-level service that only registers one set of these event listeners, and uses event delegation to apply ripple effects.
jelbourn
reviewed
Feb 27, 2020
| this._registerEvents(pointerDownEvents); | ||
| } | ||
|
|
||
| /** Handles all registered events. */ |
Contributor
There was a problem hiding this comment.
Could you add the @docs-private annotation to this JsDoc block? That will prevent it from appearing in our generated API docs.
devversion
approved these changes
Feb 27, 2020
devversion
left a comment
Member
There was a problem hiding this comment.
Looks great to me. Thanks!
diicar
reviewed
Feb 28, 2020
| this._triggerElement!.removeEventListener(type, this, passiveEventOptions); | ||
| }); | ||
|
|
||
| if (this._pointerUpEventsRegistered) { |
There was a problem hiding this comment.
the if statements is really needed here ?
Contributor
Author
There was a problem hiding this comment.
It avoids unnecessary iteration and removeEventListener() calls.
mmalerba
pushed a commit
that referenced
this pull request
Apr 14, 2020
* perf(ripple): optimize event registration Improve scalabiliity of Angular Material components. When used in an app with a large and heavy UI with large numbers of material components (for example in table cells), they can quickly become prohibitively expensive due to their heavy DOM structure and lots of up-front work. Each component with a ripple ends up registering 6 event listeners. This PR makes 4 of them registered on-demand. Note, that this is really a stop-gap solution to help improve performance in our application. A proper implementation should utilize a single document-level service that only registers one set of these event listeners, and uses event delegation to apply ripple effects. * Update core.d.ts * Add the @docs-private annotation.
This was referenced May 3, 2020
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve scalability of Angular Material components.
When used in an app with a large and heavy UI with large numbers of material components, they can quickly become prohibitively expensive due to their heavy DOM structure and lots of up-front work.
Registering event listeners is slow, and gets progressively slower as the DOM tree grows and gets more complex. Each component with a ripple ends up registering 6 event listeners. Consider a 100-row table with 6 buttons per row. That's 3600 event listeners that need to be registered during rendering. This PR makes 2400 of them registered on-demand.
Note, that this is really a stop-gap solution to help improve performance in our application. A proper implementation should utilize a single document-level service that only registers one set of these event listeners, and uses event delegation to apply ripple effects.