Skip to content

perf(mdc-checkbox, mdc-radio): Use class for MDC adapter #19980

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

Closed
wants to merge 8 commits into from

Conversation

ngwattcos
Copy link
Contributor

@ngwattcos ngwattcos commented Jul 15, 2020

Change the adapters in MatCheckbox and MatRadioButton to class objects to (hopefully) reduce memory usage or improve performance.

The Metrics

A simple test shows that the change to class-based adapter causes a statistically significant difference in performance!

Before Adapter Optimization

Times to initialize all checkboxes (milliseconds):
0.7299988065
0.7049997803
0.6649994757
0.6749990862
0.6349999458
0.6850000937
0.7099998184
0.6350008771
0.7799998857
0.6700006779
Average: 0.6889998447

After Adapter Optimization

Times to initialize all checkboxes:
0.6799995899
0.560000306
0.6049999502
0.6849993952
0.6249998696
0.6349999458
0.6699995138
0.6299999077
0.6750009488
0.639999751
Average: 0.6404999178

Overall a 7% initialization performance increase.

ngwattcos added 3 commits July 6, 2020 18:26
…ckbox adapter object.

This replaces the private _checkboxAdapter with a singleton object to reduce memory usage and hopefully improve performance.
This makes some MatCheckbox methods public in order for the singleton CheckboxAdapter to access the _attrBlacklist.
…stead of owning an adapter

Now MatRadioButton uses a singleton adapter to hopefully reduce memory and increase performance.
@ngwattcos ngwattcos requested a review from mmalerba as a code owner July 15, 2020 03:06
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 15, 2020
Added type annotations to CheckboxAdapter methods to satisfy bazel errors.
@ngwattcos ngwattcos force-pushed the optimize-adapters branch from e231df1 to ef83be6 Compare July 15, 2020 18:40
@mmalerba mmalerba changed the title Optimize adapters perf(mdc-checkbox, mdc-radio): Use class for MDC adapter Jul 23, 2020
@andrewseguin
Copy link
Contributor

@ngwattcos Would you like to rebase this change?

@andrewseguin andrewseguin added the needs: clarification The issue does not contain enough information for the team to determine if it is a real bug label Mar 24, 2022
@andrewseguin
Copy link
Contributor

Our strategy going forward with adapters is changing soon that will make this PR obsolete

@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 May 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: clarification The issue does not contain enough information for the team to determine if it is a real bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants