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

try receive data first when TryAsyncStream's poll_next. #2846

Closed
wants to merge 1 commit into from

Conversation

yuyang-ok
Copy link

@yuyang-ok yuyang-ok commented Oct 31, 2023

When I was trying to slove the this issue #2834
I found code here TryAsyncStream's poll_next can emit result without poll some Future.
And if the the channel is full, Pull some future can be slow because of send to a channel must wait.

@yuyang-ok yuyang-ok changed the title A little optimize try receive data first when TryAsyncStream's poll_next. Oct 31, 2023
@yuyang-ok
Copy link
Author

This make better use of the channel.

@abonander
Copy link
Collaborator

Buffering data in the channel is not the intent here. As written, this will read 10 rows from the connection before returning the first one, even if one row is all we're expecting.

The simple fix for the warning in #2834 is to pass a no-op waker to the channel, or just not use an async channel in the first place (futures-channel is kind of inefficient anyway because it allocates for every item sent).

@abonander abonander closed this Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants