-
Notifications
You must be signed in to change notification settings - Fork 1.2k
State is passed explicitly to instrumentation and parameters are NOT mutated #2769
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
State is passed explicitly to instrumentation and parameters are NOT mutated #2769
Conversation
…passing in state to the instrumentation fields
…licitly-to-instrumentation
…licitly-to-instrumentation # Conflicts: # src/main/java/graphql/execution/instrumentation/ChainedInstrumentation.java
…licitly-to-instrumentation
|
Hi. Wondering if there is an update on this as we're very keen to see the impact on object allocation. Thanks :) |
|
I am waiting on a final review from @andimarek - Andi? |
|
@andimarek did you get a chance to review this PR? |
|
Hello @andimarek and/or @bbakerman! Did you manage to follow up on this PR? |
…licitly-to-instrumentation # Conflicts: # src/main/java/graphql/execution/Execution.java
|
I just fixed up the merge conflict on this PR - this will be merged into 19.0 - 19.0 is to be released very soon - probably next week |
| public InstrumentationContext<ExecutionResult> beginExecution(InstrumentationExecutionParameters parameters) { | ||
| // these assert methods have been left in so that we truly never call these methods, either in production nor in tests | ||
| // later when the deprecated methods are removed, this will disappear. | ||
| return Assert.assertShouldNeverHappen("The deprecated " + "beginExecution" + " was called"); | ||
| } |
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.
FYI this is a breaking change for eg, a downstream ExecutionStrategy implementation that calls beginExecution(parameters) and needs to be changed to call beginExecution(parameters, parametersInstrumentationState). May want to update the 19.0 release notes which claim no breaking changes.
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.
thanks a lot @josephlbarnett ... will update the release notes
FlowSubscriptionExecutionStrategy needs to be updated to pass instrumentationState to instrumentations per graphql-java/graphql-java#2769
FlowSubscriptionExecutionStrategy needs to be updated to pass instrumentationState to instrumentations per graphql-java/graphql-java#2769 ValidationError string changed slightly so adjust assertions.
FlowSubscriptionExecutionStrategy needs to be updated to pass instrumentationState to instrumentations per graphql-java/graphql-java#2769 ValidationError string changed slightly so adjust assertions.
FlowSubscriptionExecutionStrategy needs to be updated to pass instrumentationState to instrumentations per graphql-java/graphql-java#2769 ValidationError string changed slightly so adjust assertions.
FlowSubscriptionExecutionStrategy needs to be updated to pass instrumentationState to instrumentations per graphql-java/graphql-java#2769 ValidationError string changed slightly so adjust assertions.
* 19.3: (709 commits) use class loader in getResource (graphql-java#3038) Stable port of graphql-java#2940 (graphql-java#2947) Stable port of Diff counts are the same (graphql-java#2946) Stable port of Fix printing directives when they contain something like a formatting specifier (graphql-java#2919) (graphql-java#2920) (graphql-java#2945) Stable port of Fix field visibility bug with enum with enum args (graphql-java#2926) (graphql-java#2944) Stable fix for graphql-java#2943 (graphql-java#2943) Added test fore intersection Xuorig Fix PR - Edge case with GraphQLTypeReference and Schema Transforms (graphql-java#2906) Fix typo in description of skip directive (graphql-java#2915) Add smaller set first optimisation Cheaper calculation for narrowing down possible objects in ENO Handles isDeprecated not being present in the json Defaults Locale when calling validation (graphql-java#2908) DF SelectionSet Benchmark (graphql-java#2893) Test stability (graphql-java#2903) Donna's catch! (graphql-java#2900) Deprecate Apollo Cache Control READY - Stop DOS attacks by making the lexer stop early on evil input. (graphql-java#2892) Bump java-dataloader ahead of release State is passed explicitly to instrumentation and parameters are NOT mutated (graphql-java#2769) ... # Conflicts: # README.md # build.gradle # src/main/java/graphql/GraphQL.java # src/main/java/graphql/Scalars.java # src/main/java/graphql/execution/ValuesResolver.java # src/main/java/graphql/relay/SimpleListConnection.java # src/main/java/graphql/schema/DataFetchingEnvironmentImpl.java
As per #2743 - object allocation at scale can be problematic because in a chained instrumentation call we create new
instrumentation parametersper chained call and we create a chainedInstrumentationContextobject (list of all the otherInstrumentationContextobjects) which gets held in memory for a long time and is not eligible for GC.This PR starts to change
Instrumentationso thatInstrumentationStateis passed into each method direct (no need for new objects to be allocated)InstrumentationContextcan be null and hence no object allocation is needed here eitherAll the places that received a
InstrumentationContexthave been changed to swap in a static NooP object (singleton) and hence they dont change a lot in a consuming sense.This PR as is shows that ALL the tests pass - that is the new methods are delegated back to the old no problems.
Some important decisions I made
I used
nulland not Optional for the emptyInstrumentationContextcase - why? Because there is no object allocation involved in thesomecase versus the empty case.The
instrumentXXXmethods have been changed to take inInstrumentationStatefor consistency reasons with all the others even if the memory pressure problem doesnt apply to them as muchThe
instrumentXXXmethods MUST return a non null object as before - I put@Nonnullannotations to this betterThe ChainedInstrumentation class has been updated to copy with null contexts being returned returned AND it only uses the new methods with state and never the old.
Still TODO
I have not updated ALL the provided instrumentations to take advantage of the new methods. I think this is best dont in a another PR to reduce the scope of this already large PR. They all work unchanged so lets not make it more complicated than it needs to be and we can improve it via another PR