Skip to content

Commit 2f75c8e

Browse files
committed
support odirect download
1 parent 74f8804 commit 2f75c8e

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

awscrt/s3.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,17 @@ class S3FileIoOptions:
186186
"""
187187
Enable direct IO to bypass the OS cache. Helpful when the disk I/O outperforms the kernel cache.
188188
Notes:
189-
- Only supported on linux for now.
190-
- Only supports upload for now.
189+
- Currently only Linux supports direct I/O. On unsupported platforms, the request transparently
190+
falls back to buffered I/O and a warning is logged.
191+
- Supported for both upload (send_filepath) and download (recv_filepath).
192+
- For upload, part_size MUST be page-aligned when direct_io is enabled (hard fail otherwise).
193+
The client controls part_size and is responsible for ensuring alignment.
194+
- For download, this is a best-effort optimization. The request transparently falls back to
195+
buffered I/O (logging a warning) if any of the following preconditions are not met:
196+
- part_size is not page-aligned
197+
- For WRITE_TO_POSITION, recv_file_position is not page-aligned
198+
- For CREATE_OR_APPEND, the existing file size is not page-aligned
199+
- The last part of the download has an unaligned length (only that part falls back)
191200
- Check NOTES for O_DIRECT for additional info https://man7.org/linux/man-pages/man2/openat.2.html
192201
In summary, O_DIRECT is a potentially powerful tool that should be used with caution.
193202
"""

0 commit comments

Comments
 (0)