Skip to content

Commit 7666afd

Browse files
committed
Expose CRT file IO options
1 parent da6c941 commit 7666afd

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

awscli/customizations/s3/factory.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ def _create_crt_client(self, params, runtime_config):
138138
create_crt_client_kwargs['crt_credentials_provider'] = (
139139
crt_credentials_provider
140140
)
141+
fio_options = {}
142+
if (val := runtime_config.get('should_stream')) is not None:
143+
fio_options['should_stream'] = val
144+
if (val := runtime_config.get('disk_throughput')) is not None:
145+
fio_options['disk_throughput_gbps'] = val
146+
if (val := runtime_config.get('direct_io')) is not None:
147+
fio_options['direct_io'] = val
148+
create_crt_client_kwargs['fio_options'] = fio_options
141149

142150
return create_s3_crt_client(**create_crt_client_kwargs)
143151

awscli/customizations/s3/transferconfig.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# commands.
1616
import logging
1717

18+
from botocore.utils import ensure_boolean
1819
from s3transfer.manager import TransferConfig
1920

2021
from awscli.customizations.s3 import constants
@@ -31,6 +32,9 @@
3132
'preferred_transfer_client': constants.AUTO_RESOLVE_TRANSFER_CLIENT,
3233
'target_bandwidth': None,
3334
'io_chunksize': 256 * 1024,
35+
'should_stream': None,
36+
'disk_throughput': None,
37+
'direct_io': None,
3438
}
3539

3640

@@ -47,9 +51,18 @@ class RuntimeConfig:
4751
'max_bandwidth',
4852
'target_bandwidth',
4953
'io_chunksize',
54+
'disk_throughput',
55+
]
56+
HUMAN_READABLE_SIZES = [
57+
'multipart_chunksize',
58+
'multipart_threshold',
59+
'io_chunksize',
60+
]
61+
HUMAN_READABLE_RATES = [
62+
'max_bandwidth',
63+
'target_bandwidth',
64+
'disk_throughput',
5065
]
51-
HUMAN_READABLE_SIZES = ['multipart_chunksize', 'multipart_threshold', 'io_chunksize']
52-
HUMAN_READABLE_RATES = ['max_bandwidth', 'target_bandwidth']
5366
SUPPORTED_CHOICES = {
5467
'preferred_transfer_client': [
5568
constants.AUTO_RESOLVE_TRANSFER_CLIENT,
@@ -62,6 +75,7 @@ class RuntimeConfig:
6275
'default': constants.CLASSIC_TRANSFER_CLIENT
6376
}
6477
}
78+
BOOLEANS = ['should_stream', 'direct_io']
6579

6680
@staticmethod
6781
def defaults():
@@ -83,6 +97,7 @@ def build_config(self, **kwargs):
8397
runtime_config.update(kwargs)
8498
self._convert_human_readable_sizes(runtime_config)
8599
self._convert_human_readable_rates(runtime_config)
100+
self._convert_booleans(runtime_config)
86101
self._resolve_choice_aliases(runtime_config)
87102
self._validate_config(runtime_config)
88103
return runtime_config
@@ -116,6 +131,12 @@ def _convert_human_readable_rates(self, runtime_config):
116131
'second (e.g. 10Mb/s or 800Kb/s)' % value
117132
)
118133

134+
def _convert_booleans(self, runtime_config):
135+
for attr in self.BOOLEANS:
136+
value = runtime_config.get(attr)
137+
if value is not None:
138+
runtime_config[attr] = ensure_boolean(value)
139+
119140
def _human_readable_rate_to_int(self, value):
120141
# The human_readable_to_int() utility only supports integers (e.g. 1024)
121142
# as strings and human readable sizes (e.g. 10MB, 5GB). It does not

awscli/s3transfer/crt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
)
3434
from awscrt.s3 import (
3535
S3Client,
36+
S3FileIoOptions,
3637
S3RequestTlsMode,
3738
S3RequestType,
3839
S3ResponseError,
@@ -44,7 +45,7 @@
4445
from botocore.exceptions import NoCredentialsError
4546
from botocore.useragent import register_feature_id
4647
from botocore.utils import ArnParser, InvalidArnException, is_s3express_bucket
47-
from s3transfer.constants import FULL_OBJECT_CHECKSUM_ARGS, MB
48+
from s3transfer.constants import FULL_OBJECT_CHECKSUM_ARGS, GB, MB
4849
from s3transfer.exceptions import TransferNotDoneError
4950
from s3transfer.futures import BaseTransferFuture, BaseTransferMeta
5051
from s3transfer.utils import CallArgs, OSUtils, get_callbacks
@@ -87,6 +88,7 @@ def create_s3_crt_client(
8788
part_size=8 * MB,
8889
use_ssl=True,
8990
verify=None,
91+
fio_options=None,
9092
):
9193
"""
9294
:type region: str
@@ -153,6 +155,9 @@ def create_s3_crt_client(
153155
target_gbps = _get_crt_throughput_target_gbps(
154156
provided_throughput_target_bytes=target_throughput
155157
)
158+
fio_options = fio_options or {}
159+
if disk_throughput := fio_options.get('disk_throughput_gbps'):
160+
fio_options['disk_throughput_gbps'] = disk_throughput * 8 / GB
156161
return S3Client(
157162
bootstrap=bootstrap,
158163
region=region,
@@ -162,6 +167,7 @@ def create_s3_crt_client(
162167
tls_connection_options=tls_connection_options,
163168
throughput_target_gbps=target_gbps,
164169
enable_s3express=True,
170+
fio_options=S3FileIoOptions(**fio_options),
165171
)
166172

167173

0 commit comments

Comments
 (0)