Skip to content

Commit

Permalink
ARROW-15036: [C++] Automatically configure S3 SDK configuration param…
Browse files Browse the repository at this point in the history
…eter "maxConnections"

This should allow uses cases where the user wants more than 25 threads in the I/O thread pool because they are doing highly concurrent S3 work.  See ARROW-14965

Closes #11929 from westonpace/feature/ARROW-15036--expose-max-connections-param

Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
westonpace authored and pitrou committed Dec 13, 2021
1 parent 2a4e634 commit 972588e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,8 @@ class ClientBuilder {

Aws::Client::ClientConfiguration* mutable_config() { return &client_config_; }

Result<std::shared_ptr<S3Client>> BuildClient() {
Result<std::shared_ptr<S3Client>> BuildClient(
util::optional<io::IOContext> io_context = util::nullopt) {
credentials_provider_ = options_.credentials_provider;
if (!options_.region.empty()) {
client_config_.region = ToAwsString(options_.region);
Expand Down Expand Up @@ -742,6 +743,11 @@ class ClientBuilder {
client_config_.proxyPassword = ToAwsString(options_.proxy_options.password);
}

if (io_context) {
// TODO: Once ARROW-15035 is done we can get rid of the "at least 25" fallback
client_config_.maxConnections = std::max(io_context->executor()->GetCapacity(), 25);
}

auto client = std::make_shared<S3Client>(
credentials_provider_, client_config_,
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
Expand Down Expand Up @@ -1617,7 +1623,7 @@ class S3FileSystem::Impl : public std::enable_shared_from_this<S3FileSystem::Imp
explicit Impl(S3Options options, io::IOContext io_context)
: builder_(std::move(options)), io_context_(io_context) {}

Status Init() { return builder_.BuildClient().Value(&client_); }
Status Init() { return builder_.BuildClient(io_context_).Value(&client_); }

const S3Options& options() const { return builder_.options(); }

Expand Down

0 comments on commit 972588e

Please sign in to comment.