-
Notifications
You must be signed in to change notification settings - Fork 125
programming model questions #100
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
Comments
This sounds sensible to me. |
If we was to always call delegate methods on a specified event loop, I am worried about the performance impact this may have. For instance, when a connection pool is added, there are cases where the most efficient solution for the pool will be to return a channel that isn't on the fixed event loop, meaning hopping would have a non-negligible performance impact from what I understand. Looking at how |
Thanks for the input @adtrevor & @ianpartridge ! That all makes sense. @adtrevor So I think in most cases, it's much more important to re-use a But, the programming model is also really important. I struggled to come up with something that would satisfy all use-cases and yet have a usable yet sensible API. Fortunately, I dropped by @Lukasa's desk and I think after talking about lots of that stuff it essentially boils down to the following options:
We believe those 3 options really cover all reasonable options. Did we miss anything? The good news here is that with minimal API changes, we could make this work. The required changes would be:
That way we can model all the scenarios above ( How does that sound? |
You can ignore my previous comment if you saw it. I was worried about a use case and did not realize this one was correctly solved by the I agree the multiple use cases mean there is no single solution that would fit all and that a finer control is needed to get the best performance, nothing seems to be missing AFAICT and yet it’s indeed a nice to use API 🙂 |
Yes, that would be the guarantee: the client would select an event loop for you. |
But, the event loop might still change during the lifetime of the request, correct? For example, if a redirect to a different host would create/reuse a connection/channel that lives on a different event loop. |
Sorry, we need to clear the language up here. There are two event loops in play. The first is the event loop used by the In this case, the loop that belongs to the |
Got it 👍 |
Thanks! That's great! I realise the only additional options that could be added would only make a really small difference and they would apply to extremely specific situations, also they could be additive changes so the options as they are right now seem perfect to me 🙂 |
Right now, the delegate's methods are calling out on essentially a random
EventLoop
.I think we have the guarantee, that each delegate method will at least be called on the same
EventLoop
?I realise that I proposed the change to have
task.currentEventLoop
(which can change) but I'm not sure anymore that was a good idea. I didn't quite realise that this means that the user has no idea on whatEventLoop
their delegate's methods will be called on.Maybe it would be better to go back to having a fixed
EventLoop
on the task and hop over in case we get a Channel from a differentEventLoop
from a connection pool.The other dimension where this matters is the
EventLoopPreference
, that also kind of means a randomEventLoop
. Maybe we should just have the user specify theEventLoop
they want (if they care, random one otherwise) and use that. If we get aChannel
from a differentEventLoop
then let's justhop(to:)
the correct one.This is just an idea really but I was thinking about the programming model earlier today and 'essentially a random EventLoop' sounds like it might lead to a lot of threading bugs?
Tagging the relevant people @adtrevor / @ianpartridge / @tanner0101 / @Lukasa / @artemredkin
The text was updated successfully, but these errors were encountered: