-
Notifications
You must be signed in to change notification settings - Fork 140
perf: optimize Uni.await() for known item/failure #2019
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2019 +/- ##
============================================
- Coverage 89.18% 89.16% -0.03%
- Complexity 3112 3122 +10
============================================
Files 412 412
Lines 13274 13295 +21
Branches 1684 1688 +4
============================================
+ Hits 11838 11854 +16
Misses 812 812
- Partials 624 629 +5
🚀 New features to boost your workflow:
|
|
Hi @mkouba, and thanks for looking into this. Do you have any benchmark / test result to share here? |
Yes, so there's a simple benchmark that basically tests
Ofc, you should take these results with a grain of salt. I didn't use a dedicated machine etc. On the other hand, it's clear that if we avoid the allocations and synchronization in |
|
Thanks @mkouba (BTW I had a look at your JMH tests, they're correct). My only real concern is that we'd be introducing a special case, but any extra operator like |
|
Just so I understand fully, can you please point me to some impacting places where we need that boost? |
|
On the commit message, I'd use |
I do understand your concern, it's not nice at all 🤷. Speaking of the referenced paper - I think that this optimization is more related to the reactive/imperative integration which can be perceived as a misuse, but it's IMO necessary for practical APIs.
Yes, so typically the API provides a method that returns If you're curious about real APIs, then for example HttpUpgradeCheck#perform() from |
|
I cannot reproduce the TCK failure locally 🤔. |
Weird, it sometimes happens that CI runners get stuck, so timing checks get broken, etc |
|
These CI failures do not make sense, especially as you haven't touched anything relevant to these. |
|
@ozangunalp it looks like we have TCK failures in CI about pausable |
|
Oh well |
|
It is still the same NPE in |
|
Return of the infamous drain loop 🤣 More seriously can I let you check and open a PR? There's no urgency, this isn't in a release yet. |
jponge
left a comment
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.
I approve this, but I will always be cautious about such kind of protocol-bypass 😄
Let's merge after the TCK fix for pausable Multi is here.
Makes sense.
👍 |
|
@mkouba it looks like your commit is not signed or the signature is not verified, and we need this (https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification#ssh-commit-signature-verification) |
- optimize the case where the item/failure is known and subscription/synchronization is not needed
Background
In Quarkus, we often design non-blocking APIs with Mutiny. We also provide a blocking variant of the API that usually defaults to
Uni.await().indefinitely(). However,UniBlockingAwaitis fairly expensive in terms of performance.It's not unusual that some parts of the API return
Uni.createFrom().item(); i.e. if the default implementation is blocking.In this pull request, we try to optimize this path and bypass the subscription/synchronization unless really needed.
I've created a simple benchmark for quarkus-flags: https://github.com/mkouba/quarkus-flags-benchmarks and the results are really good.