Repository navigation
Performance improvements to checkTypeRegistry (isSubTypeOf) - #4528
Merged
bbakerman merged 2 commits intoNov 3, 2026
Merged
Conversation
added 2 commits
November 1, 2026 11:49
…alent The equivalence shortcut relied on TypeInfo.equals, which only compared the outermost wrapper and the innermost name, so [String] was a subtype of [String!] and [[String]] of [String]. Compare names only once both sides are unwrapped, and fix TypeInfo.equals/hashCode to compare the full wrapper chain.
xuorig
force-pushed
the
perf/allocation-free-is-subtype-of
branch
from
November 2, 2026 15:22
8bafa38 to
912ed91
Compare
Contributor
Test ReportTest Results
Code Coverage (Java 25)
Changed Class Coverage (2 classes)
TypeInfo — method details
|
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.
TypeDefinitionRegistry.isSubTypeOfis called for every field an implementing type shares with each of its interfaces, as part ofSchemaTypeChecker.checkTypeRegistry, which bothSchemaGeneratorandFastSchemaGeneratorrun. On large schemas it is a very slow procedure.Each call allocated two
TypeInfos (each with anArrayDeque), plus another two per level ofNonNull/Listunwrapping. In the abstract-type case it looked up each type definition twice, once inisInterfaceOrUnion/isObjectTypeOrInterfaceand again inisPossibleType. It also used streams inimplementsInterfaceandisUnionMemberwhich similar to recent improvements to graphql-java, are changed into regular loops.Bug fix
While working on this I also found a potential bug? The "equivalent type is a valid subtype" shortcut used
TypeInfo.equals, which only compares the outermost wrapper and the innermost type name. So it returnedtruefor:As a result, the SDL type checker didn't report
InterfaceFieldRedefinitionErrorfor e.g.interface I { f: [String!] }/type T implements I { f: [String] }. With schema validation on,SchemaValidatorstill rejected these later. With validation off (withValidation(false), which could happen withFastSchemaGenerator), they were accepted.The name comparison now happens only once both sides are unwrapped to a named type. The recursion already handled the wrappers.
TypeInfo.equals/hashCodeare also fixed to compare the full wrapper chain, for anyone relying on them.