Skip to content

IO: switch Win32 pipes to PIPE_WAIT and use a sentinel byte #866

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

Merged
merged 2 commits into from
Apr 16, 2025

Conversation

compnerd
Copy link
Member

Cherry-pick changes from main to use a PIPE_WAIT-mode pipe on Windows. Additionally, steal a byte from the buffer to synchronise on as a sentinel byte to check if we are waiting on a client to read from the buffer.

@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

  • Explanation:
    Switch pipes on Windows to PIPE_WAIT mode to get a blocking pipe semantics. This allows the IOCP loop in the IO monitor to continue to make progress. We take the last byte of the buffer to synchronise the read and write buffer for the pipe.
  • Scope:
    This change impacts only pipes on Windows.
  • Issues:
    DispatchIO.read spinning while pipe is open on Windows #820
  • Original PRs:
    Switch Win32 pipes to PIPE_WAIT with sentinel bufsize #854
  • Risk:
    In theory, this change can cause dispatch clients to possibly hang in the scenario that a pipe is given to dispatch with a writer that fills the buffer and no reader that will ever drain the buffer.
  • Testing:
    LSP was used with this change and was verified to no longer cause a high CPU utilisation when idle.
  • Reviewers:
    @compnerd @rokhinip

@compnerd compnerd changed the base branch from main to release/6.2 April 16, 2025 00:57
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

@swift-ci please test Linux platform

@compnerd compnerd merged commit d1d14d9 into swiftlang:release/6.2 Apr 16, 2025
2 checks passed
@compnerd compnerd deleted the 6.2-pipes branch April 16, 2025 16:52
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