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

Improve TCP backpressure handling on Windows #4252

Merged
merged 6 commits into from
Nov 22, 2022
Merged

Improve TCP backpressure handling on Windows #4252

merged 6 commits into from
Nov 22, 2022

Conversation

SeanTAllen
Copy link
Member

Our prior setting of backpressure for TCP writes on Windows was naive. It was based purely on the number of buffers currently outstanding on an IOCP socket. The amount of data didn't matter at all. Whether more data could be accepted or not, also wasn't taken into consideration. This commit greatly improves the situation by only applying backpressure when Windows tells us that it is applying backpressure.

No more guessing.

Two runtime API methods have been updated on Windows.

The Windows version of pony_os_writev will now return the number of buffers accepted or zero if backpressure is encountered. All other errors still cause an error that must be handled on the Pony side of the API via a try block.

The Windows version of pony_os_send will now return the number of bytes accepted or zero if backpressure is encountered. All other errors still cause an error that must be handled on the Pony side of the API via a try block.

I consider these changes non-breaking as previously, the return values from both functions had no meaning.

Closes #4081

Our prior setting of backpressure for TCP writes on Windows was naive. It was
based purely on the number of buffers currently outstanding on an IOCP socket.
The amount of data didn't matter at all. Whether more data could be accepted or
not, also wasn't taken into consideration. This commit greatly improves the
situation by only applying backpressure when Windows tells us that it is
applying backpressure.

No more guessing.

Two runtime API methods have been updated on Windows.

The Windows version of `pony_os_writev` will now return the number of buffers
accepted or zero if backpressure is encountered. All other errors still cause
an error that must be handled on the Pony side of the API via a `try` block.

The Windows version of `pony_os_send` will now return the number of bytes
accepted or zero if backpressure is encountered. All other errors still cause
an error that must be handled on the Pony side of the API via a `try` block.

I consider these changes  non-breaking as previously, the return values from
both functions had no meaning.

Closes #4081
@SeanTAllen SeanTAllen requested review from chalcolith and a team November 19, 2022 22:21
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Nov 19, 2022
@SeanTAllen SeanTAllen added changelog - added Automatically add "Added" CHANGELOG entry on merge changelog - changed Automatically add "Changed" CHANGELOG entry on merge and removed discuss during sync Should be discussed during an upcoming sync changelog - added Automatically add "Added" CHANGELOG entry on merge labels Nov 19, 2022
src/libponyrt/lang/socket.c Outdated Show resolved Hide resolved
src/libponyrt/lang/socket.c Show resolved Hide resolved
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Nov 22, 2022
@SeanTAllen SeanTAllen merged commit ccd270b into main Nov 22, 2022
@SeanTAllen SeanTAllen deleted the issue-4081 branch November 22, 2022 19:11
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Nov 22, 2022
github-actions bot pushed a commit that referenced this pull request Nov 22, 2022
github-actions bot pushed a commit that referenced this pull request Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - changed Automatically add "Changed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows TCP backpressure enhancements
4 participants