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

use a buffered writer instead of manually buffering #56

Closed
wants to merge 1 commit into from

Conversation

Stebalien
Copy link
Member

Thoughts?

@Stebalien Stebalien requested a review from vyzo May 21, 2019 20:20
@Stebalien Stebalien force-pushed the feat/steb-has-opinions branch 3 times, most recently from cb80153 to 1672d65 Compare May 21, 2019 20:29
}
defer mp.closeNoWait()
if err := mp.sendLoop(); err != nil {
log.Info("send loop exited with: %s", err)
Copy link
Contributor

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

Copy link
Member Author

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:
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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:

  1. The connection is new (we'll have no data to flush so flush will be a noop).
  2. We've read some data off the data chan.

Copy link
Contributor

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.

@vyzo
Copy link
Contributor

vyzo commented May 21, 2019

Also, lots of rightwards drift.

@Stebalien
Copy link
Member Author

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.

@Stebalien Stebalien closed this May 21, 2019
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