Skip to content

Conversation

@lwfitzgerald
Copy link
Contributor

@lwfitzgerald lwfitzgerald commented Sep 29, 2025

Rationale for this change

The existing S3 remote signing hook function (s3v4_rest_signer) uses requests.post to submit POST requests to the REST signing endpoint. This internally creates a new requests.Session for every request, preventing any reuse of connections.

In my profiling I saw this add overhead from repeated loading of CA certs and reestablishing of TLS connections.

This change makes the signing function a callable object that wraps a request.Session, using this for POSTing, therefore achieving connection reuse.

Signer callables are stored on the hook internals of the aiobotocore client inside the s3fs.S3FileSystem instance, so use and lifetime will match that of those instances. They are thread-local since: #2495.

Are these changes tested?

Tested locally. Existing unit tests updated for changes.

Are there any user-facing changes?

Yes - S3 signing requests now use connection pools (scoped to the s3fs.S3FileSystem object).

The existing S3 remote signing hook function (`s3v4_rest_signer`) uses
`requests.post` to submit `POST` requests to the REST signing endpoint.
This internally creates a new `requests.Session` for every request,
preventing any reuse of connections.

In my profiling I saw this add overhead from repeated loading of CA certs
and reestablishing of TLS connections.

This change makes the signing function a callable object that wraps a
`request.Session`, using this for `POST`ing, therefore achieving
connection reuse.

Signer callables are stored on the hook internals of the `aiobotocore`
client inside the `s3fs.S3FileSystem` instance, so use and lifetime will
match that of those instances. They are thread-local since:
apache#2495.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff best viewed with whitespace changes turned off

@lwfitzgerald lwfitzgerald marked this pull request as ready for review September 29, 2025 08:12
Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, thanks @lwfitzgerald for working on this 👍

@Fokko Fokko merged commit 40521c8 into apache:main Oct 1, 2025
10 checks passed
@Fokko
Copy link
Contributor

Fokko commented Oct 1, 2025

Thanks @lwfitzgerald for working on this, and thanks @jonbannister for the review 🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants