Skip to content
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

Negative cache of Property fetch misses #1691

Conversation

bbakerman
Copy link
Member

@bbakerman bbakerman commented Nov 4, 2019

This PR changes the way a missed property is handled for performance reasons.

Previously if a field foo is defined in a schema but the underlying object did not have a getFoo() method / field then a null would be correctly returned however all the java reflection would be repeated on the next call and so on.

This means that for misconfigured SDL -> runtime code you pay a high performance penalty.

This PR fixes it so that we negatively cache missing reflection look ups and hence are more performany in certain cases (where a field is defined by not possible to retrieve)

This is much like we do for positive caching (where we keep the method/field in memory for next time)

The drawbacks of this approach is that in contrived cases, you can change the underlying class and it wont be reflected. We consider this acceptable since dynamically changing classes in Java is a tricky business at best. We provide a clear() method to reset the caches for those mucking around with dynamic classes.

@andimarek andimarek added this to the 14.0 milestone Nov 4, 2019
@bbakerman bbakerman self-assigned this Jan 13, 2020
@bbakerman bbakerman merged commit b623055 into graphql-java:master Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants