Repository navigation
Faster Property fetching with derived classes - #2019
Conversation
| // | ||
| if (isNegativelyCached(cacheKey)) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
I flipped the negative cache down in the order because I think the "positive case" is more likely - that is for any property X on a source object we have a method to get it.
So now if we DONT have a cached method we will try to see if its negatively cached (could not be found before) and the do the full search for it
This is a minor improvement because it avoids a map lookup in the case where we have methods, which I beleive is the best case to chase first
| MethodFinder methodFinder = (aClass, methodName) -> cachedMethod; | ||
| try { | ||
| return getPropertyViaGetterMethod(object, propertyName, graphQLType, methodFinder, environment); | ||
| return invokeMethod(object, environment, cachedMethod.method, cachedMethod.takesDataFetcherEnvironmentAsOnlyArgument); |
There was a problem hiding this comment.
We now do LESS work to invoke the property get
| String getterName = prefix + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); | ||
| try { | ||
| Method method = methodFinder.apply(object.getClass(), getterName); | ||
| if (takesDataFetcherEnvironmentAsOnlyArgument(method)) { |
There was a problem hiding this comment.
previously we always did this method call - now we cache this knowledge just like the method itself
|
|
||
| then: | ||
| result == "bar" | ||
| } |
There was a problem hiding this comment.
the tests all pass and I tweaked this one to ensure out caching works for Foo extends Bar case
|
Would be great to get this in the next release/backport 🚀 |
It will go out in 16.0 - we only maintain one LTS release and thats 14.x I suspect this can be backported - lets try and see |
|
Could we have a pre-release or snapshot version of this where we could test it's impacts ? |
|
@bhabegger every development build from master is available via maven central. |
|
This will result in a development build now that its merged |
I found a bug on the VERY important PropertyDataFetcher where methods on derived classes are not cached properly.
This leads to things running slower than they are intended.
We also invoke too much code when we DO have a cached method and this simplifies that, doing way less work on POJO method invocation
I created a benchmark for this - on my Mac Pro -