Skip to content

do-not-merge: IO completion port POC#40569

Draft
OneBlue wants to merge 4 commits into
masterfrom
user/oneblue/io-refactor-3
Draft

do-not-merge: IO completion port POC#40569
OneBlue wants to merge 4 commits into
masterfrom
user/oneblue/io-refactor-3

Conversation

@OneBlue
Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue commented May 15, 2026

Summary of the Pull Request

This change brings a POC of the IOCP switch.

Advantages:

  • No more 64 handles limit
  • Handles that don't support overlapped IO can be easily flagged

Drawbacks:

  • One handle can only be associated to a specific IOCP. This makes the design more complex for when we issue a read and a write on the same socket
  • If a handle is associated to another IOCP, things will hang since we can't detect the difference between "This handle doesn't support Overlapped IO" and "this handle couldn't be associated to the IOCP", which leads to additional complexity

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI review requested due to automatic review settings May 15, 2026 23:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a proof-of-concept IOCP-backed implementation for MultiHandleWait, aiming to remove the 64-handle wait limit and support IO completion routing across composite handles.

Changes:

  • Replaces GetHandle()-based waiting with Bind()-based IOCP association for overlapped IO handles.
  • Adds IOCP binding lifetime management and threadpool-wait support for event handles.
  • Adds a >64-handle unit test and quotes MSI installer/log paths in installer tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/windows/common/HandleIO.h Adds IOCP binding abstractions and updates handle interfaces for IOCP-based dispatch.
src/windows/common/HandleIO.cpp Implements IOCP binding, event posting, and MultiHandleWait IOCP run loop.
src/windows/common/precomp.h Adds <list> for the new MultiHandleWait storage.
src/windows/wslcsession/PortRelayHandle.h Updates port relay accept handle to the new Bind() interface.
src/windows/wslcsession/PortRelayHandle.cpp Binds port relay accept completions to the listening socket/overlapped pair.
test/windows/UnitTests.cpp Adds coverage for waiting on more than 64 handles.
test/windows/InstallerTests.cpp Quotes MSI command-line paths for install and log arguments.

// m_handles), each IOCPHandle's destructor detaches its kernel handle so
// external consumers (e.g. boost::asio::stream::assign, or a later
// MultiHandleWait reusing the same socket) can rebind freely.
std::map<HANDLE, IOCPHandle> m_iocpBindings;
Comment on lines +1173 to +1175
if (error == WAIT_TIMEOUT)
{
break;
Comment on lines +128 to +133
// Best-effort: not every device type supports FileCompletionNotificationModes. If
// unsupported, the worst case is a redundant packet for a synchronous success which
// is filtered out in MultiHandleWait::Run.
if (!SetFileCompletionNotificationModes(Handle, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS))
{
LOG_LAST_ERROR_IF(GetLastError() != ERROR_INVALID_FUNCTION);
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