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 — Removing some of the Optional.map() and .stream() for performance reasons by bbakerman · Pull Request #3930 · graphql-java/graphql-java

Conversation

@bbakerman

@bbakerman bbakerman commented Apr 24, 2025

Copy link
Copy Markdown
Member

Some of these are on a critical path so will help a smidge to be more performant.

Others are not and are mostly done via IDEA "rewriting" the .stream() to a direct call

Sorry, something went wrong.

Uh oh!

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

All reactions
@bbakerman
Removing some fo the Optional.map() and .stream() for performance rea…
66d527c
…sons.
@bbakerman bbakerman added the performance work that is primarily targeted as performance improvements label Apr 24, 2025
@bbakerman bbakerman added this to the 23.1 non-breaking changes and bugfixes milestone Apr 24, 2025
bbakerman
bbakerman commented Apr 24, 2025
View reviewed changes
Comment thread src/main/java/graphql/execution/Execution.java
Optional.ofNullable(executionContext.getGraphQLContext())
.map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_INCREMENTAL_SUPPORT))
.orElse(false)
executionContext.hasIncrementalSupport()

@bbakerman bbakerman Apr 24, 2025

Copy link
Copy Markdown
Member Author

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.

This is critical path stuff and is used in a number of places

Sorry, something went wrong.

Uh oh!

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

All reactions
bbakerman
bbakerman commented Apr 24, 2025
View reviewed changes
Comment thread src/main/java/graphql/execution/ExecutionStrategy.java
Optional.ofNullable(executionContext.getGraphQLContext())
.map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_INCREMENTAL_SUPPORT))
.orElse(false)
executionContext.hasIncrementalSupport()

@bbakerman bbakerman Apr 24, 2025

Copy link
Copy Markdown
Member Author

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.

This is more critical path - avoids two Optional allocations

Sorry, something went wrong.

Uh oh!

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

All reactions
bbakerman
bbakerman commented Apr 24, 2025
View reviewed changes
Comment thread ...on/instrumentation/dataloader/PerLevelDataLoaderDispatchStrategyWithDeferAlwaysDispatch.java
count++;
}
}
int nonDeferredFieldCount = count;

@bbakerman bbakerman Apr 24, 2025

Copy link
Copy Markdown
Member Author

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.

This is more critical path when defer is on

Sorry, something went wrong.

Uh oh!

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

All reactions
bbakerman
bbakerman commented Apr 24, 2025
View reviewed changes
Comment thread src/main/java/graphql/incremental/DelayedIncrementalPartialResultImpl.java
for (IncrementalPayload incrementalItem : incrementalItems) {
list.add(incrementalItem.toSpecification());
}
result.put("incremental", list);

@bbakerman bbakerman Apr 24, 2025

Copy link
Copy Markdown
Member Author

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.

critical path when defer is on

Sorry, something went wrong.

Uh oh!

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

All reactions
@github-actions

github-actions Bot commented Apr 24, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Test Results

  314 files  ±0    314 suites  ±0   53s ⏱️ -1s
3 611 tests +1  3 606 ✅ +1  5 💤 ±0  0 ❌ ±0 
3 700 runs  +1  3 695 ✅ +1  5 💤 ±0  0 ❌ ±0 

Results for commit 0d8ab56. ± Comparison against base commit 397c050.

This pull request removes 174 and adds 153 tests. Note that renamed tests count towards both.
	?
                __schema { types { fields { args { type { name fields { name }}}}}}
                __schema { types { fields { type { name fields { name }}}}}
                __schema { types { inputFields { type { inputFields { name }}}}}
                __schema { types { interfaces { fields { type { interfaces { name } } } } } }
                __schema { types { name} }
                __type(name : "t") { name }
                a1: __schema { types { name} }
                a1: __type(name : "t") { name }
                a2 :  __type(name : "t1") { name }
…
graphql.DataFetcherTest ‑ get Boolean property value [fetcher: <graphql.schema.PropertyDataFetcher@a50d709 propertyName=booleanField function=null>, #0]
graphql.DataFetcherTest ‑ get Boolean property value [fetcher: <graphql.schema.SingletonPropertyDataFetcher@2c88a3e8>, #1]
graphql.DataFetcherTest ‑ get Boolean property value with get [fetcher: <graphql.schema.PropertyDataFetcher@65f651eb propertyName=booleanFieldWithGet function=null>, #0]
graphql.DataFetcherTest ‑ get Boolean property value with get [fetcher: <graphql.schema.SingletonPropertyDataFetcher@2c88a3e8>, #1]
graphql.DataFetcherTest ‑ get property value [fetcher: <graphql.schema.PropertyDataFetcher@529c2a9a propertyName=property function=null>, #0]
graphql.DataFetcherTest ‑ get property value [fetcher: <graphql.schema.SingletonPropertyDataFetcher@2c88a3e8>, #1]
graphql.DataFetcherTest ‑ get public field value as property [fetcher: <graphql.schema.PropertyDataFetcher@73d60e76 propertyName=publicField function=null>, #0]
graphql.DataFetcherTest ‑ get public field value as property [fetcher: <graphql.schema.SingletonPropertyDataFetcher@2c88a3e8>, #1]
graphql.ScalarsBooleanTest ‑ parseValue throws exception for invalid input <java.lang.Object@6c122f96>
graphql.ScalarsBooleanTest ‑ serialize throws exception for invalid input <java.lang.Object@cb390dc>
…

♻️ This comment has been updated with latest results.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bbakerman
bbakerman requested review from andimarek and dondonz April 27, 2025 06:31
andimarek
andimarek approved these changes May 9, 2025
View reviewed changes
@andimarek

andimarek commented May 9, 2025

Copy link
Copy Markdown
Member

One thing: is Collectors.ToList really the same as ArrayList and should we initialize ArrayList with the right size if we know it?

All reactions

Sorry, something went wrong.

Uh oh!

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

bbakerman added 2 commits May 9, 2025 15:59
@bbakerman
Merge remote-tracking branch 'origin/master' into remove-optional-str…
a777920
…eams-style-code
@bbakerman
Added FpKit.arrayListSizedTo()
35eb00e
@dondonz dondonz modified the milestones: 25.x breaking changes, 24.0 May 13, 2025
dondonz
dondonz approved these changes May 14, 2025
View reviewed changes
@bbakerman
Merge remote-tracking branch 'origin/master' into remove-optional-str…
0d8ab56
…eams-style-code

# Conflicts:
#	src/main/java/graphql/util/FpKit.java
@dondonz
dondonz merged commit 0ad655c into master May 15, 2025
@dondonz
dondonz deleted the remove-optional-streams-style-code branch May 15, 2025 06:09
@dondonz dondonz mentioned this pull request May 15, 2025
Cherry pick 3930 remove optional streams #3973
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@andimarek andimarek andimarek approved these changes
@dondonz dondonz dondonz approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

performance work that is primarily targeted as performance improvements

Projects

None yet

Milestone

24.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@bbakerman @andimarek @dondonz
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.