ponyc
ponyc copied to clipboard
Windows TCP backpressure enhancements
When I put in the backpressure work in TCPConnection, I knew nothing about IOCP and Windows and as such, it is technically hooked up but may not be very effective or it might be overly effective. This issue is going to collect improvements that could be made:
pony_os_writev
For writing, in writev and write_final in TCPConnection the Windows, pony_os_writev is called. Currently on Windows, it always returns 0. However, pony_os_writev calls WSASend which handles all errors that aren't WSA_IO_PENDING as a fatal error and shuts down. I believe that WSAEWOULDBLOCK should be handled differently and if it is encountered, that is our signal to trigger backpressure more than _pending_sent length.
Moving away from _pending_sent would mean that we want to improve the logic in _complete_sent to not making release backpressure purely based on _pending_sent size.
pony_os_send
Also uses WSASend in the same way as pony_os_writev but it isn't called by anything in the standard library or runtime. We can improve the windows interface to indicate backpressure and document it.
iocp_send_to
iocp_send_to uses WSASendTo for datagrams which could also be told there is backpressure and could be adjusted as could its callers, however, we currently have no backpressure in the UDPsystem on POSIX either so this could reasonably be skipped for now and done as part of "backpressure for UDP" which... well, I'm not sure what that would look like. I've never considered backpressure for UDP.