Skip to content
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

Rewrite CompletableFutureExtension.allSettled to not use CompletableFuture.supplyAsync #1872

Merged

Conversation

roookeee
Copy link
Contributor

@roookeee roookeee commented Oct 23, 2023

We noticed a big drop in performance after switching to the new CompletableFuture based FederatedTypeResolver. Our investigations led us to the implementation of CompletableFutureExtension.allSettled which has the following issues:

  • Bug: It uses CompletableFuture.supplyAsync which looses all thread local data (as we switch to another thread pool we have no control over), which breaks most tracing frameworks and all other thread local usages
  • Performance: 100 futures get wrapped into 100 separately scheduled futures, this is unnecessary as thenApply and exceptionally work without nesting of futures. This avoids non-neglegible overhead

I changed the accompanying test to expect another exception type as only get() throw a ExecutionException. This should not affect your public API as its an internal method and I could not find any other references to ExecutionException in graphql-kotlins codebase.

@roookeee roookeee force-pushed the avoid_future_nesting_all_settled branch from f203c30 to ae902e6 Compare October 24, 2023 06:35
@samuelAndalon samuelAndalon merged commit 4c6a625 into ExpediaGroup:master Oct 24, 2023
2 of 3 checks passed
@roookeee
Copy link
Contributor Author

Could we get a bugfix release that includes this change in the near future? It's currently blocking our prod migration to graphql-kotlin 7.x because of performance regressions. Thank you!

@dariuszkuc
Copy link
Collaborator

I'll try getting two federation fixes in over the weekend (unsure why builds time out on those) and we should be able to release afterwards.

@dariuszkuc dariuszkuc added the changes: patch Changes require a patch version label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: patch Changes require a patch version
Development

Successfully merging this pull request may close these issues.

3 participants