Skip to content

feat: add Windows IOCP async file I/O in fast_io crate - #3299

Merged
oferchen merged 4 commits into
masterfrom
feat/iocp-windows
Apr 21, 2026
Merged

oferchen merged 4 commits into
masterfrom
feat/iocp-windows

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Add Windows I/O Completion Ports (IOCP) support as the Windows equivalent of Linux io_uring in the fast_io crate
  • Mirrors the io_uring architecture: feature-gated real module on Windows (#[cfg(all(target_os = "windows", feature = "iocp"))]), stub module on other platforms
  • IOCP reader supports batched concurrent overlapped reads for throughput
  • IOCP writer buffers internally and flushes via overlapped WriteFile
  • Factory pattern with automatic fallback to standard I/O when IOCP is unavailable or files are too small (< 64KB)
  • Runtime IOCP detection with AtomicU8 caching, IocpPolicy enum (Auto/Enabled/Disabled)
  • 186 tests pass on macOS (stub path); Windows path exercises real IOCP APIs

New files

  • crates/fast_io/src/iocp/ - Real IOCP module (completion_port, config, file_factory, file_reader, file_writer, overlapped)
  • crates/fast_io/src/iocp_stub.rs - Full API mirror for non-Windows

Test plan

  • All 186 fast_io tests pass on macOS (stub path)
  • Clippy clean with all features
  • CI: fmt+clippy, nextest, Windows, macOS, Linux musl
  • Windows CI validates real IOCP code compiles and tests pass

Add I/O Completion Ports support as the Windows equivalent of Linux
io_uring. Mirrors the io_uring architecture: feature-gated real module
on Windows, stub module on other platforms.

- completion_port.rs: RAII wrapper around IOCP handle
- overlapped.rs: pinned OVERLAPPED + buffer for stable async pointers
- file_reader.rs: overlapped ReadFile with batched concurrent reads
- file_writer.rs: overlapped WriteFile with internal buffering
- file_factory.rs: factory pattern with auto-fallback to std I/O
- config.rs: runtime IOCP detection with AtomicU8 caching
- iocp_stub.rs: full API mirror returning Unsupported on non-Windows
- IocpPolicy enum (Auto/Enabled/Disabled) matching IoUringPolicy
- IOCP_MIN_FILE_SIZE (64KB) threshold for async benefit
@github-actions github-actions Bot added the enhancement New feature or request label Apr 21, 2026
- Remove unused import std::os::windows::io::AsRawHandle in file_reader
- Remove unnecessary mut on writer variable in file_writer
- Allow dead_code on valid_bytes field and buffer_capacity/set_offset
  methods in overlapped.rs (public API for future callers)
@oferchen
oferchen merged commit affe28d into master Apr 21, 2026
38 checks passed
@oferchen
oferchen deleted the feat/iocp-windows branch April 21, 2026 10:57
oferchen added a commit that referenced this pull request May 1, 2026
* feat: add Windows IOCP async file I/O in fast_io crate

Add I/O Completion Ports support as the Windows equivalent of Linux
io_uring. Mirrors the io_uring architecture: feature-gated real module
on Windows, stub module on other platforms.

- completion_port.rs: RAII wrapper around IOCP handle
- overlapped.rs: pinned OVERLAPPED + buffer for stable async pointers
- file_reader.rs: overlapped ReadFile with batched concurrent reads
- file_writer.rs: overlapped WriteFile with internal buffering
- file_factory.rs: factory pattern with auto-fallback to std I/O
- config.rs: runtime IOCP detection with AtomicU8 caching
- iocp_stub.rs: full API mirror returning Unsupported on non-Windows
- IocpPolicy enum (Auto/Enabled/Disabled) matching IoUringPolicy
- IOCP_MIN_FILE_SIZE (64KB) threshold for async benefit

* fix: add Send impls for IOCP reader/writer and fix overlapped offset types

* fix: resolve Windows clippy warnings in IOCP module

- Remove unused import std::os::windows::io::AsRawHandle in file_reader
- Remove unnecessary mut on writer variable in file_writer
- Allow dead_code on valid_bytes field and buffer_capacity/set_offset
  methods in overlapped.rs (public API for future callers)
oferchen added a commit that referenced this pull request May 5, 2026
* feat: add Windows IOCP async file I/O in fast_io crate

Add I/O Completion Ports support as the Windows equivalent of Linux
io_uring. Mirrors the io_uring architecture: feature-gated real module
on Windows, stub module on other platforms.

- completion_port.rs: RAII wrapper around IOCP handle
- overlapped.rs: pinned OVERLAPPED + buffer for stable async pointers
- file_reader.rs: overlapped ReadFile with batched concurrent reads
- file_writer.rs: overlapped WriteFile with internal buffering
- file_factory.rs: factory pattern with auto-fallback to std I/O
- config.rs: runtime IOCP detection with AtomicU8 caching
- iocp_stub.rs: full API mirror returning Unsupported on non-Windows
- IocpPolicy enum (Auto/Enabled/Disabled) matching IoUringPolicy
- IOCP_MIN_FILE_SIZE (64KB) threshold for async benefit

* fix: add Send impls for IOCP reader/writer and fix overlapped offset types

* fix: resolve Windows clippy warnings in IOCP module

- Remove unused import std::os::windows::io::AsRawHandle in file_reader
- Remove unnecessary mut on writer variable in file_writer
- Allow dead_code on valid_bytes field and buffer_capacity/set_offset
  methods in overlapped.rs (public API for future callers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant