-
Notifications
You must be signed in to change notification settings - Fork 27.4k
perf($rootScope): do not mark $watchCollectionInterceptor as $stateful #16009
perf($rootScope): do not mark $watchCollectionInterceptor as $stateful #16009
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (I think)
Can you please add the info from the first post to the commit message? Otherwise LGTM. |
I think this should be |
ba5120a
to
7a1bdbc
Compare
Updated. This one could probably also go to 1.6.x if there's no objections... |
I don't have any objections. |
Fine with me |
7a1bdbc
to
6fbe208
Compare
FYI I want to look into this more and actually measure it using #16063. I think I may recall why we originally did this (or why I did it, and didn't leave a comment explaining why...). Essentially because inputs to an expression being used in But for literal expressions it sure would be nice if this flag was off since shallow-watching the inputs is all we need to do, and we can avoid constructing the literal and analyzing the collection with this interceptor etc. |
0b4cd09
to
805cc43
Compare
After a bit more investigation, just removing
I've updated the first commit to only remove I've also added a second commit which adds the (internal) concept of Locally the parsed-expressions-bp I think adding |
805cc43
to
190241b
Compare
src/ng/rootScope.js
Outdated
// Mark literals as $pure to watch literal inputs of any type. | ||
// Mark non literals as $stateful to avoid input-watching and always invoke the interceptor | ||
// since the inputs will most likely be non-simple (like collections!). | ||
$watchCollectionInterceptor.$stateful = !($watchCollectionInterceptor.$pure = $parse(obj).literal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split into 2 lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to $$pure
until documented
190241b
to
04485ef
Compare
…hing By adding a $$pure flag to the $watchCollectionInterceptor to shallow watch all inputs regardless of type when watching an object/array literal.
04485ef
to
3fb7173
Compare
Some benchmarks... when running the Old: ~5.2s, >375000kb GCed |
I think travis passed now, but github hasn't picked up the new status? |
The problem with Travis is that the deploy job isn't automatically started after one of the test jobs fails and then passes. I've restarted it manually |
I think this was a mistake from the start. This interceptor doesn't actually store any state, it just reads the inner/complex state of its input. EDIT: actually it had a purpose originally, although may no longer be as significant, see #16009 (comment)
Removing the
$stateful
flag will allow some expressions (those withinputs
such as array/object literals) to avoid invoking$watchCollectionInterceptor
and avoid creating the literals etc. on each digest.