fix(graphcache): Fix defer field state becoming sticky and affecting future fields#3167
Merged
fix(graphcache): Fix defer field state becoming sticky and affecting future fields#3167
Conversation
Member
Author
|
Unanswered question that may go along with traversal performance; cc @JoviDeCroock, {
child { id }
... @defer {
# `child` would be traversed here...
child {
id # ...because this object is present because of `id`
extra # however, here we'd run into a cache miss
}
}
}In the above case, we can see that we have a need for defer to become recursive. I can submit a small fix for this after this comment, however, this highlights the need for us to optimise traversal further Edit: Fix is submitted and fields now are marked as deferred recursively across traversals |
JoviDeCroock
approved these changes
Apr 20, 2023
ea41be5 to
89a8e4b
Compare
89a8e4b to
4ee6fc2
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #3161
Note: This will need a rebase after #3165 is merged and should be merged on top.
Summary
A rather old regression would cause
@deferdirectives to manipulate thedeferRefstate and then become “sticky”, meaning that all future fields would also be considered deferred.Instead, we need to make sure that this field resets properly and that the state returns to normal.
On a side-note, I tried to convert
makeSelectionIteratorto a generator function, since this would make it more elegant, but an initial rough implementation decreased overall cache read/write performance by 15–20%, so we'll have to investigate whether there's more we can do here. In general, traversal is the most expensive part of the cache operations, so if we can instead make it faster we'd profit from that quite a lot.Set of changes
makeSelectionIteratorto resetdeferRefmakeSelectionIterator