Repository navigation
Description
Summary
Document how to turn off the checksums that botocore adds to uploads by default, and measure what they cost the S3 filesystems.
Background
Since botocore 1.36, request_checksum_calculation defaults to "when_supported": the SDK computes a CRC32 checksum for every PutObject and UploadPart request, also when the caller asks for none, and response_checksum_validation defaults to "when_supported", which validates full-object GetObject responses. With "when_required", the SDK computes request checksums only for operations that require one, such as DeleteObjects.
PyAthena already lets users choose this:
- through a connection:
connect(..., s3_config=Config(request_checksum_calculation="when_required")), whichConnectionmerges overconfigfor its S3 client (pyathena/connection.py); - for an
S3FileSystembuilt without a connection:config_kwargs={"request_checksum_calculation": "when_required"}.
The filesystem sends ChecksumAlgorithm only when the caller sets one on the upload (S3Core multipart primitives), so the default checksums come from the SDK alone.
Gaps
- The S3 client section of the usage guide shows
s3_configonly withmax_pool_connections, and the filesystem guide does not mention the checksum settings. - Their cost was not measured. In Measure the filesystem suite against s3fs on c8gn.2xlarge #1318, PyAthena's and s3fs's writes and puts took about the same CPU time (for example 22.6 to 25.9 seconds for a 6 GiB write with PyAthena and 23.8 to 24.2 with s3fs, which uses the same botocore handlers through aiobotocore); how much of it the default checksums take is not known.
Plan
- Let the filesystem suite pass botocore settings to the S3 client of every API, or add
request_checksum_calculationandresponse_checksum_validationto its[filesystem]settings. - Measure
writeandputat medium, large, and xlarge, andreadandgetat medium and large, with the default and with"when_required", on onec8gn.2xlarge, recording throughput and CPU time; this can share a host with Measure the S3 filesystems on free-threaded Python 3.15t #1324 or the re-measurement of Run the batch operations of S3FileSystem concurrently #1322 and Download in parallel ranges in get_file() #1323. - Document the settings, with their effect on data integrity (the uploaded parts then carry no end-to-end checksum, while TLS still protects them in transit) and the measured cost, in the usage guide's S3 client section, and refer to them from the filesystem guide.
Activity
laughingman7743 commentedon Nov 12, 2026
Plan item 3 is done without the measured cost in #1393 (the "Checksums" subsection of the S3 client section in
docs/usage.md, referred to fromdocs/filesystem.md). Plan items 1 and 2 remain, and the measured cost belongs in the same subsection.While writing it, the premise of item 3 turned out to be wrong, which changes what item 2 measures.
when_requiredreplaces the CRC32 with a signed SHA-256With
request_checksum_calculation="when_required", PutObject and UploadPart do not go out without an integrity check. When an S3 request carries nox-amz-checksum-*orContent-MD5header, botocore signs the body with SHA-256, also over HTTPS (S3SigV4Auth._should_sha256_sign_payloadinbotocore/auth.py), and S3 checks the received data against the signed hash.Request headers on botocore 1.43.102 (captured with a
before-sendhook, withoutawscrt):when_supported)aws-chunkedtrailer,X-Amz-Content-SHA256: STREAMING-UNSIGNED-PAYLOAD-TRAILERwhen_requiredX-Amz-Content-SHA256: <SHA-256 of the body>when_required+s3={"payload_signing_enabled": False}X-Amz-Content-SHA256: UNSIGNED-PAYLOADwhen_required+anon=TrueA live PutObject with
when_requiredand the signed payload succeeded.So
when_requiredalone swaps the CRC32 of the body for a SHA-256 of the body. Only the third and fourth rows send an upload without any body check.Proposal for plan item 2
Measure
writeandputwith three client configurations instead of two:request_checksum_calculation="when_required";request_checksum_calculation="when_required"withs3={"payload_signing_enabled": False}.Plan item 1 then needs to pass the
s3option as well, so the suite should take any botocoreConfigoptions rather than only the two checksum settings.Read side
For reads, configuration 2 changes less than the plan assumed:
ChecksumMode=ENABLED. This was checked live on a single-part object. Reads ofS3Fileandget()are therefore never validated, whatever the setting.cat_file()without a range, are validated.botocore[crt].The
read/getcases of item 2 are therefore expected to show no difference.Say where a run takes the filesystem clients from (GH-1325)
Address the independent review of the client options (GH-1325)
Check the client options without creating an S3 client (GH-1325)
Accept the checksum values that botocore accepts (GH-1325)
Merge pull request #1407 from pyathena-dev/feat/1325-benchmark-client…
laughingman7743 commentedon Nov 16, 2026
Plan item 2 ran in the re-measurement of #1332, at
1d9e5039on onec8gn.2xlargeSpot host, with the three client sets of the proposal above (#1407); the history entry and the measured cost in the Checksums subsection ofdocs/usage.mdare in #1420.All cases used 40 workers, a pool of 40, and 8 MiB parts.
Uploads of 1 GiB and 6 GiB with PyAthena were faster without the default CRC32. Ratios are to the default throughput:
when_requiredwhen_required+payload_signing_enabled=Falsewhen_requiredtook the same CPU time, 10.8 to 11.7 seconds for 6 GiB. The unsigned payload took 34 to 39% less.Why the default may be slower. This is read from botocore 1.43.102's source, not profiled:
aws-chunkedstream of 1 MiB chunks with a CRC32 trailer.when_required, the part goes out as aBytesIOwithout that framing, with its SHA-256 hash signed.s3fs.
write, which sends one part at a time, ran within 0.93 to 1.05 times of the default with every setting.put_file()ran at 0.80 to 0.86 times withwhen_required, and at 1.10 to 1.38 times with the unsigned payload.Reads and downloads ran within 0.93 to 1.05 times of the default with every API, as expected.