René's URL Explorer Experiment


Title: Reuse collected sub fields for objects of the same type by Meemaw · Pull Request #4501 · graphql-java/graphql-java · GitHub

Open Graph Title: Reuse collected sub fields for objects of the same type by Meemaw · Pull Request #4501 · graphql-java/graphql-java

X Title: Reuse collected sub fields for objects of the same type by Meemaw · Pull Request #4501 · graphql-java/graphql-java

Description: Problem ExecutionStrategy.completeValueForObject runs FieldCollector.collectFields for every object in the result. For a list of N objects this repeats the same work N times: walking the selection set, evaluating @skip/@include, expanding fragments and building a fresh LinkedHashMap + MergedFields + MergedSelectionSet. The result only depends on the merged field, the resolved object type, the variables and the fragments, and the last two are fixed for an execution. Async-profiler on ExecutionBenchmark showed field collection at ~16% of CPU and ~20% of allocated bytes. Change The collected sub fields are memoized per execution in ExecutionContext, keyed by MergedField and then by the resolved GraphQLObjectType. Every object of the same type under the same field reuses the same immutable MergedSelectionSet. Sub fields are shared too, so cache hits cascade down the tree. Key correctness: MergedField.equals compares the class and the AST Field nodes (Field uses identity), so two merged fields are only equal when they come from exactly the same set of AST fields. Interface/union results are keyed per concrete object type. Fallback to the old per-object collection when: incremental support (@defer) is enabled, because DeferredExecution instances are created per collection, or a custom ConditionalNodeDecision is in the GraphQLContext, because the callback is not guaranteed to be deterministic. Memory: the cache is bounded by the number of distinct (field, object type) pairs in the operation and lives only as long as the ExecutionContext. API surface: this adds a field to ExecutionContext plus one @Internal getter, getCollectedSubFields(). Happy to move it elsewhere if you prefer. Benchmarks Apple Silicon, JDK 21. Base vs this branch jars were run interleaved (alternating, 3 rounds × 2 forks each = 6 forks per side) to cancel out machine drift. Δ shows the 95% confidence interval. Benchmark Throughput Δ Allocated bytes/op ExecutionBenchmark.benchmarkThroughput +14.7% ± 7.0% 1,073,041 → 903,689 (−15.8%) SimpleQueryBenchmark.benchMarkSimpleQueriesThroughput +10.2% ± 9.8% 1,933,273 → 1,510,351 (−21.9%) IntrospectionBenchmark (large-schema-2) +19.4% ± 9.0% 112.3M → 98.2M (−12.6%)¹ An earlier run on a quieter machine of the same change (before a cosmetic computeIfAbsent refactor) gave tighter intervals: ExecutionBenchmark +9.3% ± 0.8%, SimpleQuery +15.0% ± 1.1%, Introspection +18.4% ± 8.1%. An A/A run (base vs base) on that machine showed no significant difference, with a noise floor of about ±1.8% on ExecutionBenchmark. ¹ Introspection bytes/op vary between forks even for the same jar (96.9M vs 114.5M observed for base), so treat that row as indicative only. Tests New CollectedSubFieldsReuseTest covers: objects of different concrete types in the same interface list each get their own type's fields aliased fields with different sub selections are collected separately fields merged across fragments keep all their sub selections collection happens once per (field, object type) a non-deterministic ConditionalNodeDecision is still asked for every object, so the cache is bypassed the cache is bypassed when incremental support is enabled To check the tests guard the fallbacks, I temporarily removed the bypass condition: the ConditionalNodeDecision test then returned wrong data and the incremental test failed. The full test suite passes, apart from the 14 locale-dependent StringValueParsingUnicodeTest failures that also occur on master with a non-English JVM locale (fixed separately in #4500). 🤖 Generated with Claude Code

Open Graph Description: Problem ExecutionStrategy.completeValueForObject runs FieldCollector.collectFields for every object in the result. For a list of N objects this repeats the same work N times: walking the selection ...

X Description: Problem ExecutionStrategy.completeValueForObject runs FieldCollector.collectFields for every object in the result. For a list of N objects this repeats the same work N times: walking the selection ...

Opengraph URL: https://github.com/graphql-java/graphql-java/pull/4501

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c58aa57d-da4e-ca2f-6ef9-9c94f78e223b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBCE4:1AE20C:23ADB46:2D234BF:6B017C6C
html-safe-noncef51b9578ac0d5b7891aef7accef9be0dae6b61fc32f69cf9ba8570c5d4fc77b4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0U0OjFBRTIwQzoyM0FEQjQ2OjJEMjM0QkY6NkIwMTdDNkMiLCJ2aXNpdG9yX2lkIjoiODU5Mzg4ODAzMzg4MTgxNjE3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4ba8e42a12ac75d1f537e2adf1ebc5e7a7eb0713f69c717cea5f2cc3f73f0c8f
hovercard-subject-tagpull_request:4909314017
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/graphql-java/graphql-java/pull/4501/files
twitter:imagehttps://avatars.githubusercontent.com/u/8524109?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/8524109?s=400&v=4
og:image:altProblem ExecutionStrategy.completeValueForObject runs FieldCollector.collectFields for every object in the result. For a list of N objects this repeats the same work N times: walking the selection ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git
octolytics-dimension-user_id14289921
octolytics-dimension-user_logingraphql-java
octolytics-dimension-repository_id38602457
octolytics-dimension-repository_nwographql-java/graphql-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id38602457
octolytics-dimension-repository_network_root_nwographql-java/graphql-java
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/graphql-java/graphql-java/pull/4501/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fgraphql-java%2Fpull%2F4501%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fgraphql-java%2Fpull%2F4501%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=graphql-java%2Fgraphql-java
Reloadhttps://github.com/graphql-java/graphql-java/pull/4501/files
Reloadhttps://github.com/graphql-java/graphql-java/pull/4501/files
Reloadhttps://github.com/graphql-java/graphql-java/pull/4501/files
graphql-javahttps://github.com/graphql-java
graphql-javahttps://github.com/graphql-java/graphql-java
Codehttps://github.com/graphql-java/graphql-java
Issues27 (27)https://github.com/graphql-java/graphql-java/issues
Pull requests35 (35)https://github.com/graphql-java/graphql-java/pulls
Discussionshttps://github.com/graphql-java/graphql-java/discussions
Actionshttps://github.com/graphql-java/graphql-java/actions
Projectshttps://github.com/graphql-java/graphql-java/projects
Wikihttps://github.com/graphql-java/graphql-java/wiki
Security and qualityhttps://github.com/graphql-java/graphql-java/security
Insightshttps://github.com/graphql-java/graphql-java/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fgraphql-java%2Fgraphql-java%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgraphql-java%2Fgraphql-java%2Fissues%2Fnew%2Fchoose
Meemawhttps://github.com/Meemaw
graphql-java:masterhttps://github.com/graphql-java/graphql-java/tree/master
Meemaw:perf/reuse-collected-sub-fieldshttps://github.com/Meemaw/graphql-java/tree/perf/reuse-collected-sub-fields
Conversation 1 https://github.com/graphql-java/graphql-java/pull/4501
Commits 2 https://github.com/graphql-java/graphql-java/pull/4501/commits
Checks 10 https://github.com/graphql-java/graphql-java/pull/4501/checks
Files changed https://github.com/graphql-java/graphql-java/pull/4501/files
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4501/files
Reuse collected sub fields for objects of the same type https://github.com/graphql-java/graphql-java/pull/4501/files#top
Show all changes 2 commits https://github.com/graphql-java/graphql-java/pull/4501/files
fa2ca87 Reuse collected sub fields for objects of the same type Meemaw Oct 18, 2026 https://github.com/graphql-java/graphql-java/pull/4501/commits/fa2ca87df7b7ba8fac70fc4514e564d8d2c2f190
8bfb212 Merge branch 'master' into perf/reuse-collected-sub-fields andimarek Oct 30, 2026 https://github.com/graphql-java/graphql-java/pull/4501/commits/8bfb212ef0119a44c8e5e6ddbd5b81416478561c
Clear filters https://github.com/graphql-java/graphql-java/pull/4501/files
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4501/files
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4501/files
ExecutionContext.java https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
ExecutionStrategy.java https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
CollectedSubFieldsReuseTest.groovy https://github.com/graphql-java/graphql-java/pull/4501/files#diff-53fefee4e2b0854e95ed576aae1e4174113508aa4b2d978159ab2530a61546f3
src/main/java/graphql/execution/ExecutionContext.javahttps://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
View file https://github.com/graphql-java/graphql-java/blob/8bfb212ef0119a44c8e5e6ddbd5b81416478561c/src/main/java/graphql/execution/ExecutionContext.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/graphql-java/graphql-java/pull/4501/{{ revealButtonHref }}
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-494b2e14b6ff313b065fdfa8af71cee8d31709e3b8bc12049fed22bf7c34476f
src/main/java/graphql/execution/ExecutionStrategy.javahttps://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
View file https://github.com/graphql-java/graphql-java/blob/8bfb212ef0119a44c8e5e6ddbd5b81416478561c/src/main/java/graphql/execution/ExecutionStrategy.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/graphql-java/graphql-java/pull/4501/{{ revealButtonHref }}
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
https://github.com/graphql-java/graphql-java/pull/4501/files#diff-2ece51452808f5a3fd08db50de534a12806aa6cd4e236c549dff9759884e43ff
src/test/groovy/graphql/execution/CollectedSubFieldsReuseTest.groovyhttps://github.com/graphql-java/graphql-java/pull/4501/files#diff-53fefee4e2b0854e95ed576aae1e4174113508aa4b2d978159ab2530a61546f3
View file https://github.com/graphql-java/graphql-java/blob/8bfb212ef0119a44c8e5e6ddbd5b81416478561c/src/test/groovy/graphql/execution/CollectedSubFieldsReuseTest.groovy
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/graphql-java/graphql-java/pull/4501/{{ revealButtonHref }}
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4501/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.