-
Notifications
You must be signed in to change notification settings - Fork 248
feat(change_detection): treat List properties as pure #763
Conversation
This PR recognizes |
FYI: Travis complains about 1/4 builds failing, but this failure comes from the master branch. |
@@ -282,13 +282,14 @@ class DirtyCheckingChangeDetector<H> extends DirtyCheckingChangeDetectorGroup<H> | |||
} | |||
|
|||
Iterator<Record<H>> collectChanges({EvalExceptionHandler exceptionHandler, | |||
AvgStopwatch stopwatch}) { | |||
AvgStopwatch stopwatch, bool isFirstPass}) { |
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.
I don't like the name.
The class should not be aware of why/when it is called. isFirstPass
means that collectChanges know it will be called multiple times.
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.
I had a hard time thinking of a good name and settled on isFirstPass
to start off with. How about resetDirtyArgs
, or clearDirtyCache
. Ah, I think that this is functionally accurate: clearMemoizationArgCache
(cf. memoization).
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.
Actually, clearMemoizationCache
would do (as it is implicitly a caching of argument values).
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.
Hmm, actually, we are just clearing a (dirty) bit, not the cached arg values. Maybe just clearDirtyArgs
? Let me know which you prefer.
I like the idea but the naming seem wrong to me, see my inline comments. |
Nice expression, I should try to remember it ;) |
Addressed your concerns. Awaiting your feedback on which name you prefer. Here is another possibility: |
Thanks. I need a little bit of thinking for the best name... I'll come back to you |
Ok. In the meantime, I re-pushed edits and went with |
if (stopwatch != null) stopwatch.start(); | ||
DirtyCheckingRecord changeTail = _fakeHead; | ||
DirtyCheckingRecord current = _recordHead; // current index | ||
|
||
int count = 0; | ||
while (current != null) { | ||
if (reMemoizeForPureFunc == null || reMemoizeForPureFunc) current.dirtyArgs = true; |
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.
this line will significantly impact the dirty checking speed. This is the core loop and it has to have minimal set of property accesses.
There are two issues with this PR:
We could fix 1 so I am not going to worry about this now. I don't believe that it is the right thing because ever digest will cause a new reverse instance creation which will negatively affect the GC pressure. While it makes the stabilization assertion pass, it is not the right thing since it will allow a lot of garbage to be created on each digest. Also there is no good way to enumerate all of the types which this will effect. For example same argument can be applied to Maps. This PR randomly special cases few types and makes them special which will make it hard to explain to people why are they special. Why does this work on List but not on my type which does the same thing. People could subclass list and this behavior would be wrong. There is a perfectly good solution to this, which is to use filters. For this reason I don't think this is an issue. I understand that this used to work, but the cost is too great and I don't think the cost outweighs the benefits. So I am going to close this PR without merging. I know you worked hard on this PR, and I appreciate your work it just does not fit the vision we have for angular. I am sorry. |
I appreciate you taking the time to respond. I thought that there might be a change that this would prove useful, but I understand that I don't have the overarching vision of the product evolution that you do. Given that you favor filters, would you be open to the addition of general purpose filters to the AngularDart pre-declared filter set? E.g., right now there is
|
FYI, #771 is a concrete proposal of the ideas suggested in my last comment. |
No description provided.