-
Notifications
You must be signed in to change notification settings - Fork 3
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
Poll all streams when not ready #34
Poll all streams when not ready #34
Conversation
if any_pending { | ||
// If any stream is not ready, return pending and tell the executor to wake us up | ||
// to try again when it is ready | ||
cx.waker().wake_by_ref(); |
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 have found, like @berkaysynnada, that it is required to call the waker here in order to have the sort preserving merge stream polled again.
I am somewhat worried about the use of wake_by_ref
as I worry it may result in a busy loop (as I think it signals to tokio to call poll
again as soon as possible (likely after trying to poll each input stream)
BTW I also confirmed that the ready!
macro does not invoke the wake_by_ref
https://docs.rs/futures-core/0.3.30/src/futures_core/task/poll.rs.html#5
Thank you for sharing your thoughts @alamb. My initial solution was actually quite similar to what you have suggested in this PR. However, there is a scenario that I believe isn't covered by the current tests:
To prevent multiple polls on a partition that returns |
My reading of the current code, namely Is that it will also potentially call There is https://docs.rs/futures/latest/futures/prelude/stream/trait.StreamExt.html#method.fuse that ensures it is actually ok to call a stream multiple times with My concern with the design in apache#12302 is that it doesn't actually poll all exhausted input streams (it only polls streams that haven't started yet). So in my mind while it solves the "do a first poll on each stream" it doesn't actually do what the comments imply it should do, which is // Ensure all non-exhausted streams have a cursor from which
// rows can be pulled If we do decide to go with the design in apache#12302 I recommend:
|
You are right, the previous design could indeed lead to multiple polls on a partition that has already returned
My design also ensures all non-exhausted streams have a cursor from which rows can be pulled (after several waking-up's of If any one of the partitions does not return a
). But now, they are guarded by If you're not entirely comfortable with the design, we can continue iterating on it. Otherwise, I'll go ahead and incorporate your recommendations. Thanks again @alamb for your time. |
I am convinced :) Upon further thought I think your design in apache#12302 seems reasonable. I think we can improve the comments to make the rationale easier to follow but the code seems good. I will comment there as well |
* Postgres: enforce required `NUMERIC` type for `round` scalar function (#34) Includes initial support for dialects to override scalar functions unparsing * Document scalar_function_to_sql_overrides fn
Proposed change to apache#12302 for polling stream when not ready
This is an alternate implementation for apache#12302 for when an input stream is not ready