Cache field and type lookups in Visibility::Profile#5586
Merged
Conversation
Owner
|
Awesome, thanks for this. It looks like something went wrong, maybe with freezing the object. My first guess is that we need to pre-fill the cache in this method: graphql-ruby/lib/graphql/schema/visibility/profile.rb Lines 306 to 309 in 9b17bfa Probably |
Memoize the results of field(owner, field_name) and type(type_name) since validation traverses the same fields/types repeatedly, especially when expanding fragments. Safe because profiles are per-query objects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e1ccd1e to
85f0404
Compare
Collaborator
Author
|
Tests are good with that |
Owner
|
Thanks for this improvment! |
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.
Memoize the results of
field(owner, field_name)andtype(type_name)since validation traverses the same fields/types repeatedly, especially when expanding fragments. Safe because profiles are per-query objects.This optimization really only shows up with visibility profiles enabled like you'd have in production. I forced a validation profile and pre-warmed it on the validation benchmarks and then the existing ones were 11-18% faster with this optimization. I've included that new
validate_profilebenchmark but not sure if there's a better way to do them.Extracted from #5578