GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Performance issue in `makeSchema` with schemas containing a lot of extensions by xuorig · Pull Request #4020 · graphql-java/graphql-java

Conversation

@xuorig

@xuorig xuorig commented Jun 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

For schemas with a large amount of object extensions, makeSchema can allocate a lot of memory due to the immutable nature of TypeRegistry.*extensions().

The main culprit is src/main/java/graphql/schema/idl/ImplementingTypesChecker.java which repeatedly calls objectTypeExtensions and interfaceTypeExtensions. (first commit)

buildObjectType is also an issue. (second commit).

First commit fix on ImplementingTypesChecker should make a lot of sense, but for buildObjectType, I'd love your opinions. I can cache all kinds of extensions on BuildContext (only did object type for now, as that was our issue).

Can also discuss if there should be cheaper getters on TypeRegistry. I welcome your thoughts!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Marc-Andre Giroux added 2 commits June 23, 2025 14:53
Marc-Andre Giroux
get interface and object type extensions only once in ImplementingTyp…
af82ae7
…esChecker
Marc-Andre Giroux
cache object type extensions on BuildContext
ab8b9ca
@bbakerman

bbakerman commented Jun 24, 2025

Copy link
Copy Markdown
Member

I think this PR is a good work around. However cheaper accessors is the way forward really

Can also discuss if there should be cheaper getters on TypeRegistry. I welcome your thoughts!

yeah the code today is old and crusty

    public Map<String, List<ObjectTypeExtensionDefinition>> objectTypeExtensions() {
        return new LinkedHashMap<>(objectTypeExtensions);
    }

This idea of copying the objects should be replaced by ImmutableXX collections - we have embraced this elsewhere in the graphql code base but not here is seems.

if we had immutables in place then

return buildCtx.getTypeRegistry().objectTypeExtensions().getOrDefault(typeDefinition.getName(), emptyList());

and

        return buildCtx.objectTypeExtensions.getOrDefault(typeDefinition.getName(), emptyList());

would be the same cost

xuorig reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bbakerman

bbakerman commented Jun 24, 2025

Copy link
Copy Markdown
Member

Ahh I just had a look at the code - its embraced mutability up the wazoo

typeRegistry.add(x)
typeRegistry.merge(otherTypeReg)

Hmmm immutability is now tricky because its relying on mutability when being built (versus being read)

I am wary that we could make this embrace immutability and not break everyone - is the juice worth the squeeze ??

We need some new structure when its passed in as a "read only" world to say SchemaGenerator and so on

Spitballing this could be

ImmutableTypeRegistry locked =  typeRegistry.readOnly()

and then key code could be hanged to used here. In some ways this is what you did when you threaded the "copied" lists into the read only places

Hmmmm tricky to fix systemically

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bbakerman

bbakerman commented Jun 24, 2025

Copy link
Copy Markdown
Member

ok this PR is probably more systemic

#4021

Now the code covered in this PR gets a graphql.schema.idl.ImmutableTypeDefinitionRegistry and hence asking for the values repeatedly give out the same object and not a copy of the maps

xuorig reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xuorig

xuorig commented Jun 24, 2025

Copy link
Copy Markdown
Contributor Author

That's great @bbakerman 🚀🚢

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xuorig

xuorig commented Jun 24, 2025

Copy link
Copy Markdown
Contributor Author

Closing in favor of #4021

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xuorig xuorig closed this Jun 24, 2025
@rstata rstata mentioned this pull request Dec 20, 2025
GraphQLSchema.FastBuilder for High-Performance Schema Construction #4196
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@xuorig @bbakerman
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.