-
Notifications
You must be signed in to change notification settings - Fork 21
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
use a buffered writer instead of manually buffering #56
Conversation
cb80153
to
1672d65
Compare
1672d65
to
dc5e729
Compare
} | ||
defer mp.closeNoWait() | ||
if err := mp.sendLoop(); err != nil { | ||
log.Info("send loop exited with: %s", err) |
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.
that probably should be debug
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.
Yeah, probably.
case data = <-mp.writeCh: | ||
case <-mp.shutdown: | ||
return nil | ||
case <-writeTimer.C: |
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.
so wait, what happens if we got no data when the timer fires?
I think we are going to end up getting lots of interrupts from this for idle connections.
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.
We go to line 206 and wait.
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.
we'll get a fired timer then if the wait is arbitrary before we are doing any coalescing.
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.
Ah, I see. Yeah, we'll "flush" no data. But we should only get to this point if:
- The connection is new (we'll have no data to flush so flush will be a noop).
- We've read some data off the data chan.
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 am more concerned about waiting a bit, having the timer fire while we are waiting for data, and then see it as immediately fired without actually coalescing anything.
Also, lots of rightwards drift. |
Well, we could use gotos for that. But your point about flushing too eagerly is right. It's mitigated by polling the input channel before even checking the deadline but still. Closing for now. |
Thoughts?