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
Avoiding Async array copies #2839
Conversation
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.
Overall I approve of this approach. We can know up front how many CFs we have and hence this will stop a list allocation which gets turned into an array allocation. We can go straight to an array allocation of the right size.
It would be interesting to see if ImmutableList.Builder on the returned results ended up faster of slow - it depends on the lifetime of the objects involved of course and how often they get copied into some other list
overallResult.completeExceptionally(exception); | ||
return; | ||
} | ||
List<T> results = Collections.singletonList(completableFuture.join()); |
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.
Use ImmutabeList.of()
-we prefer the guava lists where possible
063dc72
to
552e2df
Compare
A typed interface to build CompletableFuture.allOf without intermediate List allocations.
aba559d
to
8e62993
Compare
@bbakerman please have another look, I should have covered all your inputs... |
@bbakerman @andimarek hi guys :)
while profiling in YourKit, I spotted some extra array allocations for CompletableFuture. This is still an idea... and a work in progress... please have a look :-) There is a special handling for SelectionSet of only 1 field: in this case the array allocation could be removed completely.
Baseline:
After this PR:
is about 5-6% better on my machine (that is quite old, so maybe it is less on newer machines). Do you see other hot spots where this could beneficial?