Skip to content

Document and measure the default upload checksums of the S3 client #1325

Closed

Description

@laughingman7743

Related to #1315 and #1318.

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")), which Connection merges over config for its S3 client (pyathena/connection.py);
  • for an S3FileSystem built 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

  1. The S3 client section of the usage guide shows s3_config only with max_pool_connections, and the filesystem guide does not mention the checksum settings.
  2. 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

  1. Let the filesystem suite pass botocore settings to the S3 client of every API, or add request_checksum_calculation and response_checksum_validation to its [filesystem] settings.
  2. Measure write and put at medium, large, and xlarge, and read and get at medium and large, with the default and with "when_required", on one c8gn.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.
  3. 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

  1. laughingman7743 commented on Nov 12, 2026

    @laughingman7743
    MemberAuthor

    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 from docs/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_required replaces the CRC32 with a signed SHA-256

    With request_checksum_calculation="when_required", PutObject and UploadPart do not go out without an integrity check. When an S3 request carries no x-amz-checksum-* or Content-MD5 header, botocore signs the body with SHA-256, also over HTTPS (S3SigV4Auth._should_sha256_sign_payload in botocore/auth.py), and S3 checks the received data against the signed hash.

    Request headers on botocore 1.43.102 (captured with a before-send hook, without awscrt):

    Configuration PutObject / UploadPart
    default (when_supported) CRC32 in an aws-chunked trailer, X-Amz-Content-SHA256: STREAMING-UNSIGNED-PAYLOAD-TRAILER
    when_required no checksum header, X-Amz-Content-SHA256: <SHA-256 of the body>
    when_required + s3={"payload_signing_enabled": False} X-Amz-Content-SHA256: UNSIGNED-PAYLOAD
    when_required + anon=True no checksum, no signature

    A live PutObject with when_required and the signed payload succeeded.

    So when_required alone 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 write and put with three client configurations instead of two:

    1. default;
    2. request_checksum_calculation="when_required";
    3. request_checksum_calculation="when_required" with s3={"payload_signing_enabled": False}.

    Plan item 1 then needs to pass the s3 option as well, so the suite should take any botocore Config options rather than only the two checksum settings.

    Read side

    For reads, configuration 2 changes less than the plan assumed:

    • A ranged GetObject returns no checksum, even with ChecksumMode=ENABLED. This was checked live on a single-part object. Reads of S3File and get() are therefore never validated, whatever the setting.
    • Only whole-object GETs, such as cat_file() without a range, are validated.
    • An object uploaded without a checksum gets a CRC64NVME from S3. botocore validates CRC64NVME only with botocore[crt].

    The read/get cases of item 2 are therefore expected to show no difference.

  2. laughingman7743 commented on Nov 16, 2026

    @laughingman7743
    MemberAuthor

    Plan item 2 ran in the re-measurement of #1332, at 1d9e5039 on one c8gn.2xlarge Spot host, with the three client sets of the proposal above (#1407); the history entry and the measured cost in the Checksums subsection of docs/usage.md are 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:

    Object when_required when_required + payload_signing_enabled=False
    1 GiB 1.17 to 1.28 1.38 to 1.46
    6 GiB 1.41 to 1.45 (up to 1,623 MiB/s) 1.64 to 1.66 (up to 1,840 MiB/s)
    • The default and when_required took the same CPU time, 10.8 to 11.7 seconds for 6 GiB. The unsigned payload took 34 to 39% less.
    • For 256 MiB, the other settings ran within 0.96 to 1.16 times of the default.

    Why the default may be slower. This is read from botocore 1.43.102's source, not profiled:

    • With the default, each part goes out as an aws-chunked stream of 1 MiB chunks with a CRC32 trailer.
    • With when_required, the part goes out as a BytesIO without that framing, with its SHA-256 hash signed.
    • The HTTP connection reads either body in botocore's 128 KiB blocks.

    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 with when_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions