Removing some of the Optional.map() and .stream() for performance reasons#3930
Merged
Removing some of the Optional.map() and .stream() for performance reasons#3930
Conversation
bbakerman
commented
Apr 24, 2025
| Optional.ofNullable(executionContext.getGraphQLContext()) | ||
| .map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_INCREMENTAL_SUPPORT)) | ||
| .orElse(false) | ||
| executionContext.hasIncrementalSupport() |
Member
Author
There was a problem hiding this comment.
This is critical path stuff and is used in a number of places
bbakerman
commented
Apr 24, 2025
| Optional.ofNullable(executionContext.getGraphQLContext()) | ||
| .map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_INCREMENTAL_SUPPORT)) | ||
| .orElse(false) | ||
| executionContext.hasIncrementalSupport() |
Member
Author
There was a problem hiding this comment.
This is more critical path - avoids two Optional allocations
bbakerman
commented
Apr 24, 2025
| count++; | ||
| } | ||
| } | ||
| int nonDeferredFieldCount = count; |
Member
Author
There was a problem hiding this comment.
This is more critical path when defer is on
bbakerman
commented
Apr 24, 2025
| for (IncrementalPayload incrementalItem : incrementalItems) { | ||
| list.add(incrementalItem.toSpecification()); | ||
| } | ||
| result.put("incremental", list); |
Member
Author
There was a problem hiding this comment.
critical path when defer is on
Contributor
Test Results 314 files ±0 314 suites ±0 53s ⏱️ -1s 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.♻️ This comment has been updated with latest results. |
andimarek
approved these changes
May 9, 2025
Member
|
One thing: is Collectors.ToList really the same as ArrayList and should we initialize ArrayList with the right size if we know it? |
dondonz
approved these changes
May 14, 2025
…eams-style-code # Conflicts: # src/main/java/graphql/util/FpKit.java
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.
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