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
Experimental: use Normalized fields instead of lazy collect field #2358
base: master
Are you sure you want to change the base?
Conversation
@dfa1 hey Davide .... It would be really great if you could try out this experimental version and let us know if it improved your performance. Thanks a lot |
@andimarek of course! It looks very interesting... :-) Would be possible to publish this branch in maven central? |
@dfa1 It is published as |
@andimarek there is a breaking change in a
Not sure if this replacement is good enough for production usage:
|
another breaking change is:
|
@andimarek using yourkit with cpu tracing profilter. I cannot see anymore the "collectField" hotspot. This is really nice result! 🥇 However, I can't push this version up to the integration env since I'm not sure about my fixes for the breaking changes in |
MergedField newMergedField = normalizedQueryTree.getNormalizedFieldToMergedField().get(child); | ||
subFieldsMap.put(child.getResultKey(), newMergedField); | ||
} | ||
MergedSelectionSet subFields = MergedSelectionSet.newMergedSelectionSet().subFields(subFieldsMap).build(); |
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 feels like a bit of code that could be in NormalizedQueryTree
MergedSelectionSet subFields = normalizedQueryTree.getSelectionSet(normalisedField, resolvedObjectType);
@andimarek what is the result of this experiment? |
Super interested to understand the feasibility and any thoughts on how it could be achieved (especially what would need to be break out the query runtime variables). Our project relies on DataFetchingSelectionSets with some fairly large/deep queries. We are seeing a large portion of time spent calculating this, so if we can cache this it would be a large win. |
Hello, this pull request has been inactive for 60 days, so we're marking it as stale. If you would like to continue working on this pull request, please make an update within the next 30 days, or we'll close the pull request. |
This change leverages the normalized query structure to collect the merged subfields instead of calling
collectFields
on demand.This aims to improve the performance for especially large and deep queries with a lot of overlapping fields: the theory is that a one time build Normalized query is faster than the lazy/on demand
collectFields
code.If this really improves the performance needs to be verified.
This potentially also enables caching of a normalized query which means the merging of overlapping fields could be cached.
One aspect to consider is that a NQ is currently not independent of the variables: it needs all variables present to be build.