Repository navigation
feat(fast_io): add macOS F_NOCACHE + writev optimized write path (#1657) - #3998
Merged
Merged
Conversation
Add a macOS-specific file writer that combines two optimizations for large sequential writes: - F_NOCACHE via fcntl bypasses the unified buffer cache for files above 1 MB, reducing memory pressure without alignment requirements. - writev scatter-gather I/O batches multiple buffers into a single syscall, reducing transition overhead. Small files below the threshold use standard buffered I/O. Non-macOS platforms compile a stub that delegates to BufWriter. The module follows the same cfg-gated pattern as io_uring and IOCP with platform stubs.
Clippy flags `assert!(CONST > 0)` as `assert!(true)` since the compiler evaluates and optimizes it away. Use `assert_eq!` with the expected value instead.
Keep both macOS F_NOCACHE/writev and Windows ReFS reflink capabilities in platform_io_capabilities doc comment.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…) (#3998) * feat(fast_io): add macOS F_NOCACHE + writev optimized write path (#1657) Add a macOS-specific file writer that combines two optimizations for large sequential writes: - F_NOCACHE via fcntl bypasses the unified buffer cache for files above 1 MB, reducing memory pressure without alignment requirements. - writev scatter-gather I/O batches multiple buffers into a single syscall, reducing transition overhead. Small files below the threshold use standard buffered I/O. Non-macOS platforms compile a stub that delegates to BufWriter. The module follows the same cfg-gated pattern as io_uring and IOCP with platform stubs. * fix: replace assertions on constants with value equality check Clippy flags `assert!(CONST > 0)` as `assert!(true)` since the compiler evaluates and optimizes it away. Use `assert_eq!` with the expected value instead.
Merged
3 tasks
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…) (#3998) * feat(fast_io): add macOS F_NOCACHE + writev optimized write path (#1657) Add a macOS-specific file writer that combines two optimizations for large sequential writes: - F_NOCACHE via fcntl bypasses the unified buffer cache for files above 1 MB, reducing memory pressure without alignment requirements. - writev scatter-gather I/O batches multiple buffers into a single syscall, reducing transition overhead. Small files below the threshold use standard buffered I/O. Non-macOS platforms compile a stub that delegates to BufWriter. The module follows the same cfg-gated pattern as io_uring and IOCP with platform stubs. * fix: replace assertions on constants with value equality check Clippy flags `assert!(CONST > 0)` as `assert!(true)` since the compiler evaluates and optimizes it away. Use `assert_eq!` with the expected value instead.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…) (#3998) * feat(fast_io): add macOS F_NOCACHE + writev optimized write path (#1657) Add a macOS-specific file writer that combines two optimizations for large sequential writes: - F_NOCACHE via fcntl bypasses the unified buffer cache for files above 1 MB, reducing memory pressure without alignment requirements. - writev scatter-gather I/O batches multiple buffers into a single syscall, reducing transition overhead. Small files below the threshold use standard buffered I/O. Non-macOS platforms compile a stub that delegates to BufWriter. The module follows the same cfg-gated pattern as io_uring and IOCP with platform stubs. * fix: replace assertions on constants with value equality check Clippy flags `assert!(CONST > 0)` as `assert!(true)` since the compiler evaluates and optimizes it away. Use `assert_eq!` with the expected value instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MacosWriterincrates/fast_io/src/macos_io.rscombiningF_NOCACHEcache bypass (viafcntl) andwritevscatter-gather I/O for large sequential file writes on macOSF_NOCACHEis applied only to files above the 1 MB threshold (F_NOCACHE_THRESHOLD); smaller files use standard buffered I/O where the cache is beneficialBufWriterwith the same public API, following the same pattern asio_uring_stub.rsandiocp_stub.rsset_nocache(),is_nocache_set(), andwritev_buffers()exposed for callers managing their own file handlesplatform_io_capabilities()now reportsF_NOCACHEandwritevon macOSTest plan
small_file_skips_nocache- verifies F_NOCACHE is not set below thresholdlarge_file_enables_nocache_on_macos- verifies F_NOCACHE is set above thresholdthreshold_boundary_below/threshold_boundary_exact- boundary tests at 1 MBwrite_and_read_roundtrip- basic write/read correctnesswrite_large_payload_roundtrip- 64 KB payload correctnesswrite_above_threshold_with_nocache- write correctness with F_NOCACHE activewritev_buffers_multiple_buffers- scatter-gather batches multiple bufferswritev_buffers_empty/writev_buffers_single_buffer- edge caseswrite_chunks_exceed_flush_threshold- auto-flush via writev when pending exceeds 256 KBflush_on_drop_writes_data- Drop impl flushes pending buffersmultiple_flush_calls_are_idempotent- repeated flush is safecreate_invalid_path_returns_error- error handling for bad pathsset_nocache_returns_expected_value- standalone F_NOCACHE utility