Skip to content

Commit c8c605c

Browse files
authored
S3FileIoOptions.direct_io now supports download as well (#750)
1 parent 0bb3f49 commit c8c605c

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

awscrt/s3.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,19 @@ class S3FileIoOptions:
185185
direct_io: bool = False
186186
"""
187187
Enable direct IO to bypass the OS cache. Helpful when the disk I/O outperforms the kernel cache.
188-
Notes:
189-
- Only supported on linux for now.
190-
- Only supports upload for now.
188+
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, recv_file_position is not page-aligned (WRITE_TO_POSITION),
197+
existing file size is not page-aligned (CREATE_OR_APPEND), or the last part has an
198+
unaligned length (only that part falls back).
191199
- Check NOTES for O_DIRECT for additional info https://man7.org/linux/man-pages/man2/openat.2.html
200+
192201
In summary, O_DIRECT is a potentially powerful tool that should be used with caution.
193202
"""
194203

crt/aws-lc

0 commit comments

Comments
 (0)