Skip to content

Avoid expensive lookup in DefaultDgsDataLoaderProvider - #2273

Merged
paulbakker merged 1 commit into
masterfrom
default-dgs-data-loader-provider
Feb 3, 2026
Merged

paulbakker merged 1 commit into
masterfrom
default-dgs-data-loader-provider

Conversation

@kilink

@kilink kilink commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Avoid calling DataLoaderRegistry#getKeys, as it copies the key set; instead use getDataLoader to check if an existing DataLoader is registered with the supplied name.

Additionally, clean up DefaultDgsDataLoaderProvider:

  • Use Kotlin extensions on ApplicationContext
  • Remove unnecessary casts

An allocation profile from a production app shows that a lot of allocations occur due to this getKeys call:

image

Avoid calling DataLoaderRegistry#getKeys, as it copies the key set; instead use getDataLoader to check if
an existing DataLoader is registered with the supplied name.

Additionally, clean up DefaultDgsDataLoaderProvider:

- Use Kotlin extensions on ApplicationContext
- Remove unnecessary casts
@paulbakker
paulbakker merged commit dc32d4b into master Feb 3, 2026
2 checks passed
@kilink
kilink deleted the default-dgs-data-loader-provider branch February 3, 2026 18:26
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