Skip to content

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

Merged
compnerd merged 2 commits into
swiftlang:release/6.2from
compnerd:6.2-pipes
Apr 16, 2025
Merged

IO: switch Win32 pipes to PIPE_WAIT and use a sentinel byte#866
compnerd merged 2 commits into
swiftlang:release/6.2from
compnerd:6.2-pipes

Conversation

@compnerd

Copy link
Copy Markdown
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
Copy Markdown
Member Author

@swift-ci please test

@compnerd

Copy link
Copy Markdown
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
Copy Markdown
Member Author

@swift-ci please test

@compnerd

Copy link
Copy Markdown
Member Author

@swift-ci please test Linux platform

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