-
Notifications
You must be signed in to change notification settings - Fork 2
[M2] Improve acknowledgements. #19
Description
Depends on #36
Feature description
ACK frames serve as both: a method to ensure reliable delivery (just in case the remote client shuts down), and a way of basic flow control.
The way it is currently implemented can be improved to allow greater performance.
Is your feature request related to a problem? Please describe.
In the current state of the system, a (*dmsg.Transport).Write() operation awaits to receive an ACK frame from the remote Client. This is both time consuming and resource-intensive (as we have to use ioutil.AckWaiter to align sequences of both ends of the transport).
Describe the solution you'd like
dmsg.Transportshould have fields that keep track of the local and remote window sizes (the buffer size left in bytes).REQUESTandACCEPTframes should contain window sizes. And each edge keeps track of the remote edge's window size and stops sending when it is maxed out (when this happens, theWriteoperation should block).Writeoperations no longer needs to wait for anACKframe from remote.ACKframes are sent on everyReadoperation and contain the number of bytes read. The remote then increases the tracked window size by that amount.
Describe alternatives you've considered
We can also make the dmsg.Server be responsible for sending the ACK frames after the FWD is forwarded. However, this doesn't give us the ability to do flow control, and it is not as performant as the aforementioned solution.
Possible implementation
- Add window size fields to
dmsg.Transport - Add window sizes to
REQUESTandACCEPTframes. - Remove awaiting for
ACKafterWrite()operation. - Send
ACKafter everyRead()operation, which includes number of bytes read. - Add logic to handle
ACKframes, that adds to remaining window size. -
Writeoperation should block until remote window size frees up.