Repository navigation
std.Io: implement file_read_streaming and file_write_streaming - #363
Conversation
…aming Reuses the existing ev.PipeRead / ev.PipeWrite completions, which already perform readv / writev at the fd's current position (prep_readv/prep_writev with offset=-1 on io_uring, plain readv/writev elsewhere). For streaming reads a 0-byte result is mapped to error.EndOfStream, and BrokenPipe (not in FileReadStreaming.Error) is mapped to Unexpected. Tests skip on Windows: regular files there can't do streaming I/O through the OVERLAPPED/IOCP path without an explicit offset.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds vectored streaming file I/O: new completion types and ops for FileReadStreaming/FileWriteStreaming, io_uring native support, thread-pool fallbacks wired across backends and blocking/pathways, and user-facing streaming read/write implementations and tests. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Streaming file I/O (reads/writes using the current file position) can't use the pollable PipeRead/PipeWrite path, because regular files aren't registerable with epoll/kqueue (EPERM). Dispatch dedicated ops that use native io_uring prep_readv/prep_writev with offset=-1 on Linux and fall back to the thread pool on other backends.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/ev/backends/common.zig`:
- Around line 150-168: The streaming handlers handleFileReadStreaming and
handleFileWriteStreaming must guard against using current-position I/O on
Windows: detect the Windows target (e.g., via comptime or
std.os.identifier/Windows build tag) at the start of each function and
immediately set the completion error to error.Unexpected
(c.setError(error.Unexpected)) and return, instead of calling
fs.readv/fs.writev; otherwise the code should continue to call
fs.readv/fs.writev as before. Update both functions to perform that OS check and
early-return error.Unexpected on Windows-only paths.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c6d7a71d-86db-4eff-b2e0-39f8ff670e04
📒 Files selected for processing (11)
src/ev/backends/common.zigsrc/ev/backends/epoll.zigsrc/ev/backends/io_uring.zigsrc/ev/backends/iocp.zigsrc/ev/backends/kqueue.zigsrc/ev/backends/poll.zigsrc/ev/blocking.zigsrc/ev/completion.zigsrc/ev/loop.zigsrc/ev/root.zigsrc/io.zig
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 1 unresolved review comment. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 1 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <[email protected]>
Summary
.file_read_streamingand.file_write_streamingarms ofoperateImplvia newfileReadStreamingImpl/fileWriteStreamingImplhelpers.ev.PipeRead/ev.PipeWritecompletions, which already performreadv/writevat the fd's current position (prep_readv/prep_writevwith offset-1on io_uring, plainreadv/writevelsewhere) — no new backend ops needed.error.EndOfStream, and remapBrokenPipe(not part ofFileReadStreaming.Error) toUnexpected. Write error sets match up without remapping.Test plan
./check.sh --full— 425 tests pass on Linux../check.sh --target x86_64-windows --wine --filter "file streaming"— tests skip cleanly on Windows (regular files can't do current-position I/O via the OVERLAPPED/IOCP path).io: file streaming read advances position and reports EOF— three sequential reads returning 5, 5, thenerror.EndOfStream.io: file streaming write advances position and appends— exercises header-only, multi-slice, and splat>1 writes, read back positionally.