Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Performance degradation in angular1.3 from angular1.2 #9609

Closed
barnash opened this issue Oct 14, 2014 · 9 comments
Closed

Performance degradation in angular1.3 from angular1.2 #9609

barnash opened this issue Oct 14, 2014 · 9 comments

Comments

@barnash
Copy link

barnash commented Oct 14, 2014

When trying to render a simple input element within an ng-repeat over an array:

<div ng-repeat="a in array">
    <input ng-model="a.something">
</div>

Checkout these two js-fiddles:
Angular1.3.0
Angular1.2.26

These js-fiddles run the same example on two angularjs libraries.
The code measures how much time it takes for the digest loop to run when we're changing the array into a new array with 1, 10 and 30 elements.

There is about a 30% degradation when running the code with angular1.3. I ran it on Macbook Pro and Air, on Safari and Chrome.

This issue is related to this Stack Overflow issue

@IgorMinar
Copy link
Contributor

We need to look into this more, but by not using jQuery you can get a significant perf boost.

Angular 1.3 + jQuery 1: http://jsfiddle.net/7cjbpgjo/
Angular 1.3 + jQuery 2: http://jsfiddle.net/2gfw2z1t/3/
Angular 1.3 + no jQuery: http://jsfiddle.net/j0yhnpxk/1/

@IgorMinar
Copy link
Contributor

@jbedard would you like to take a look a this one?

@jbedard
Copy link
Contributor

jbedard commented Oct 14, 2014

I'm away for the next week, but currently stuck on a train so...

From what I can tell it is mainly caused by jQuery2 Data being slower then jQuery1, caused by http://code.google.com/p/chromium/issues/detail?id=378607 but also from the use of defineProperties. See http://bugs.jquery.com/ticket/14839, jquery/jquery@0cdec79 (which should mostly fix the issue in the next jQuery2 release, at least for chrome) and hopefully jquery/jquery#1668 will put it back on par with jQuery1.

Other things that seem to have slowed down (from a quick profiling in chrome):

  • ngModelWatch - $$runValidators added a lot of time on change/initial-call (and this test really only has the initial call)
  • NgModelController - the constructor itself has more initialization now, but overall it's actually faster due to b1ee538

@mgol
Copy link
Member

mgol commented Oct 14, 2014

@IgorMinar The test case at http://jsfiddle.net/j0yhnpxk/1/ doesn't work for at least two reasons.

@lgalfaso
Copy link
Contributor

@mzgol http://jsfiddle.net/j0yhnpxk/3/ should work now

@vitaly-t
Copy link

It is usually a selling point for newer libraries to offer better performance. When it goes the other way round it is always frustrating. I hope Angular team will be able at least to bring the performance to the same level as 1.2.

As for the problem described by barnash, his issue with the performance is more like around improper use of the input elements on the page. I just added my comment on that Stack Overflow issue, link for which he provided, explaining why having too many inputs on the same page is always a bad idea.

@barnash
Copy link
Author

barnash commented Oct 16, 2014

Thanks for the answer @VitalyTomilov.
I think that it's still a problem in the new version of Angular, I replied on SO to your answer in order to keep this discussion on topic.

@jbedard
Copy link
Contributor

jbedard commented Nov 28, 2014

bb4d3b7 and bf6a79c should both help with this a bit...

@petebacondarwin
Copy link
Member

Angular 1.4 seems to be faster: http://jsfiddle.net/5shyqe3m/

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

No branches or pull requests

8 participants