Skip to content
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

[Checkbox] Major performance problems #2832

Closed
evelant opened this issue Jan 8, 2016 · 19 comments
Closed

[Checkbox] Major performance problems #2832

evelant opened this issue Jan 8, 2016 · 19 comments

Comments

@evelant
Copy link

evelant commented Jan 8, 2016

Checkboxes are VERY slow. I have a list of 50 items each each with 2 checkboxes, making a total of 100 checkboxes. This takes almost a second to render on a 4.2ghz i7 in the latest chrome.

The top two entries from Perf.printWasted() when rendering this list

Owner > component                Wasted time (ms)           Instances
"EnhancedSwitch > ClearFix" 320.1149999999725   200
"TaskContainer > Checkbox"  217.61999999996624  86

If I remove the two material ui checkboxes and replace them with normal inputs rendering time drops from over 700ms to around 70ms. The material checkboxes make rendering this list 10x slower!

@oliviertassinari
Copy link
Member

@fignuts Thanks for raising this issue.
I'm really questioning the value of our internal <ClearFix />. It sounds like it's here to prevent issues with floating.

I strongly convinced that we should switch ⚡ from the float layout to the flexbox layout model.
It has two performance advantages:

The best part is that it should be straightforward to change. Easy task for great output 😁.

@oliviertassinari oliviertassinari changed the title Major performance problems [Checkbox] Major performance problems Jan 8, 2016
@joyfulelement
Copy link

This can be easily reproduced with the table component (http://www.material-ui.com/#/components/table).

In addition to rendering time for the table with checkboxes, the table selection behaviour (i.e. checking the checkbox behaviour) would take around 4 seconds to complete with 501 rows table. This was on Intel 3GHz 4 core machine with latest Chrome.

Suggest to verify the performance fix along with the table component for the best result.

@aweary
Copy link
Contributor

aweary commented Feb 5, 2016

I see a similar issue with DropDownMenu as well.

Owner > component Wasted time (ms) Instances
"DropDownMenu > ClearFix" 59.62000000000000273 50
"DropDownMenu > NavigationArrowDropDown" 29.830000000000382 50

I'd say that on most of my pages that ~70% of wasted time is from some MUI component.
@oliviertassinari any updates on this? Are performance improvements on the roadmap at all?

@mbrookes
Copy link
Member

mbrookes commented Feb 5, 2016

@aweary - yes, but the guys have been focusing on getting the core cleaned up to make way for these sorts of improvements. As always, PRs are welcome.

@alitaheri
Copy link
Member

@aweary We are moving towards more functional programming. Soon we will be able to memoize the styles, that will drastically reduce the number of instantiations.

@hmeerlo
Copy link

hmeerlo commented Mar 22, 2016

Experiencing the same problem but at a much larger scale. I have more than 1200 rows in a table with a Checkbox to select them. There is 21 seconds (!) wasted in the Checkbox. The time wasted seems to be exponential to the number of checkboxes.

@stewartcelani
Copy link

Also ran into this issue and have had to remove checkboxes for the moment. Was only using 8 on the page at the time but the component containing the checkbox has to rerender every 2.5-5 seconds based on DB updates so was getting a noticeable fps drop every re-render.
Pity because they're so pretty. =D

@mmazzarolo
Copy link

Any news regarding this issue?
Having the same problem in a Table with ~80 rows with checkboxes.
You can see an example here

@ziadloo
Copy link

ziadloo commented Apr 22, 2016

Just to share my findings on the subject, I've conducted a test using a table of 100 rows and 10 columns, once with checkboxes and one other time without them. Of course presence of checkboxes made it slower but even without them the performance needed a boost.

In my test, using Chrome's Timeline, selecting a row with presence of the checkboxes resulted in 450ms while without them the same action took 150ms. Of course it's still too much. I'm not sure how to do a more precise measurement as the row selection is an internal operation and there's no place to put Perf.start and Perf.stop!

In any case I'm grateful for the great work, thanks.

@sunewt
Copy link

sunewt commented May 19, 2016

Hey guys - Really interesting insight into the problem in these discussions. We're running into the same problems with checkboxes as the rest. Is it possible to get an update on any work towards improvements in this area?
By the way, keep up the good work. Material-UI is solid bar the few hiccups!

@gmaclennan
Copy link

I had a similar problem and I fixed it by making each checkbox 'pure' with recompose:

import makePure from 'recompose/pure'
import Checkbox from 'material-ui/Checkbox'
const FasterCheckbox = makePure(Checkbox)

This wraps Checkbox in a Higher Order Component which adds a shouldComponentUpdate that only updates when props change.

@sunewt
Copy link

sunewt commented May 19, 2016

@gmaclennan Thanks for sharing! Unfortunately it doesn't seem to make a difference when creating a "large" amount of checkbox components (40-50)

@mark-stopka
Copy link

I believe, this issue should be closed in favor of #3289.

@Tzelon
Copy link

Tzelon commented Oct 6, 2016

Hey,
Is there any easy solution for this ?

@oliviertassinari
Copy link
Member

@Tzelon Depending on your specific issue. But most of the time it's a bottleneck when re-rendering many Checkboxes. It that case, you should prune the rendering tree.

As #4769 was closed, the performance issue with this component should be solved. I'm closing the issue. Thanks guys.

@tietthinh
Copy link

I'm using the example provided from the Demo and I produce 143 RadioButton and it seem still slow
Here is the log from Chrome:

[Violation] 'click' handler took 169ms
[Violation] 'click' handler took 187ms
[Violation] 'click' handler took 196ms

So I'm wonder if the CheckBox fixs work for the RadioButton? Thanks

@oliviertassinari
Copy link
Member

@tietthinh You can follow the discussion in #10892.

@nhhockeyplayer
Copy link

I am using 36 checkboxes and seeing degradation onclick that spans seconds though I do have some processing going on beneath its a bit unusual

using latest material 2 angular 8

@oliviertassinari
Copy link
Member

@nhhockeyplayer We only support React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests