-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Check structural equality in QueryInfo#setDiff, again. #7997
Conversation
@benjamn The other concerns are more practical. The studio team indicated that they were having issues with cache.evict not re-triggering network requests (PR 3097 in studio). Is this a use-case we’re supporting? Because I have no idea what cache eviction has to do with queries re-firing. I would like to make sure we have a better handle on their use-case. Additionally, my current understanding of these optimism caches is that they are performance optimizations, equality checks aside. What is the impact of using structural equality checking here? The unknowns are compounded by the fact that this new canonicalization is layered on top of the optimism-based caching so I am very much in the dark about whether there are good reasons to switch from referential equality to structural equality here. For these reasons, I am unable to approve or disapprove of this PR. Of course, I’m still somewhat new to this codebase and defer to your expertise. |
@brainkim I agree this pipeline could be simplified, but I think it would be wise to separate the following two questions:
My goal with this distinction is to suggest that the second question is much easier to answer (no, watched queries should never receive the same deeply equal data twice in a row), and justifies the changes in this PR, without requiring a full answer to the first question (though I would love to keep thinking about that too). As for the Studio |
Maybe a unit test would be in order, if this is the case? What exactly is the public expectation which would fail if we didn’t use structural equality here? |
Similar to #7997, but further upstream.
@brainkim I'm all for a test, but that will have to wait on making it possible to opt out of canonization (which is something I'm planning for v3.4 but haven't gotten to yet). |
Similar to #7997, but further upstream.
Similar to #7997, but further upstream.
Similar to #7997, but further upstream.
Revisiting PR #6891, which was reverted by commit c2ef68f. With the introduction of canonical cache results (#7439), the strict equality check in setDiff is about to become mostly synonymous with deep equality checking (but much faster to check), so we need to deal with the consequences of #6891 one way or another. As evidence that this change now (after #7439) has no observable impact, notice that we were able to switch back to using !equal(a, b) without needing to fix/update any failing tests, compared to the few tests that needed updating in #6891. However, by switching to deep equality checking, we allow ourselves the option to experiment with disabling (or periodically clearing) the ObjectCanon, which would presumably lead to broadcasting more !== but deeply equal results to cache.watch watchers. With deep equality checking in setDiff, those !== results will get past the filter in the same cases canonical objects would, so there's less of a discrepancy in client behavior with/without canonization enabled.
4f1babc
to
e3ec93d
Compare
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.
The pieces are falling into place it seems.
Similar to #7997, but further upstream.
Similar to #7997, but further upstream.
Similar to #7997, but further upstream.
Similar to #7997, but further upstream.
Revisiting PR #6891, which was reverted by commit c2ef68f.
With the introduction of canonical cache results (#7439), the strict equality check in
setDiff
is about to become mostly synonymous with deep equality checking (but much faster to check), so we need to deal with the consequences of #6891 one way or another.As evidence that this change now (after #7439) has no observable impact, notice that we were able to switch back to using
!equal(a, b)
without needing to fix/update any failing tests, compared to the handful of tests that needed updating in #6891.However, by switching to deep equality checking, we allow ourselves the option to experiment with disabling (or periodically clearing) the
ObjectCanon
, which would presumably lead to broadcasting more!==
(but deeply equal) results tocache.watch
watchers.With deep equality checking in
setDiff
, those!==
results will get past thesetDiff
filter in the same cases canonical objects would, so there will be less of a discrepancy in client behavior with/without canonization enabled.