Skip to content

Removing some of the Optional.map() and .stream() for performance reasons #3930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bbakerman
Copy link
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

@bbakerman bbakerman added the performance work that is primarily targeted as performance improvements label Apr 24, 2025
Optional.ofNullable(executionContext.getGraphQLContext())
.map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_INCREMENTAL_SUPPORT))
.orElse(false)
executionContext.hasIncrementalSupport()
Copy link
Member Author

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

Optional.ofNullable(executionContext.getGraphQLContext())
.map(graphqlContext -> graphqlContext.getBoolean(ExperimentalApi.ENABLE_INCREMENTAL_SUPPORT))
.orElse(false)
executionContext.hasIncrementalSupport()
Copy link
Member Author

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

count++;
}
}
int nonDeferredFieldCount = count;
Copy link
Member Author

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

for (IncrementalPayload incrementalItem : incrementalItems) {
list.add(incrementalItem.toSpecification());
}
result.put("incremental", list);
Copy link
Member Author

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

Copy link
Contributor

github-actions bot commented Apr 24, 2025

Test Results

  314 files    314 suites   53s ⏱️
3 586 tests 3 581 ✅ 5 💤 0 ❌
3 675 runs  3 670 ✅ 5 💤 0 ❌

Results for commit 35eb00e.

♻️ This comment has been updated with latest results.

@bbakerman bbakerman requested review from andimarek and dondonz April 27, 2025 06:31
@andimarek
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance work that is primarily targeted as performance improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants