-
Notifications
You must be signed in to change notification settings - Fork 169
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
Reduce redundant flush wakes #933
Conversation
Use a sleep that is only active if we see a command rather than an interval that is always active and waking.
d83be63
to
0995691
Compare
@@ -338,6 +337,12 @@ impl ConnectionHandler { | |||
mut receiver: mpsc::Receiver<Command>, | |||
) -> Result<(), io::Error> { | |||
loop { | |||
let flush_sleep = if self.flush_wanted { | |||
tokio::time::sleep(self.flush_period).boxed() |
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.
This will create a lot of allocator noise. What if we made the Interval
very high (a few days long) when we don't want any flushes, and lowered it back to the configured value when we want it back?
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.
Forget that. There's no way to change an Interval
's interval. I wander if we ignored the first tick,
if it would stop waking the runtime up.
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.
Or we could make our own Interval
wrapper around Sleep
This function can be called both before and after the future has completed.
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.
This will create a lot of allocator noise.
Aye, but we can take it out again with a little bit of work.
Or we could make our own Interval wrapper around Sleep
Yeah short rundown is that we'd want to return pending when flush not wanted, store the waker, wake up when flush wanted is.
Closing in favor of #1070 |
Closes #923
See #905