Skip to content

ARROW-10788: [C++] Make S3 recursive tree walks parallel - #8818

Closed
pitrou wants to merge 3 commits into
apache:masterfrom
pitrou:ARROW-10788-s3-walk-async
Closed

pitrou wants to merge 3 commits into
apache:masterfrom
pitrou:ARROW-10788-s3-walk-async

Conversation

@pitrou

@pitrou pitrou commented Dec 2, 2020 •

Copy link
Copy Markdown
Member

Use the AWS SDK async APIs to launch child directory reads concurrently as soon
as we get the required information from a parent read.

Also, similarly issue directory tree deletion commands in parallel.

On this machine, listing the entire directory tree at "s3://mf-nwp-models/arome-france/v2/2020-12-02"
goes down from 12 seconds to 2 seconds (a 6x speedup, for 12944 directory entries).

@github-actions

github-actions Bot commented Dec 2, 2020

Copy link
Copy Markdown

@pitrou
pitrou force-pushed the ARROW-10788-s3-walk-async branch from 1f8fb48 to f88fc45 Compare December 2, 2020 17:29

@bkietz bkietz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, just some style nits

Comment thread cpp/src/arrow/filesystem/s3fs.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: having a Start method on a handler is counter intuitive. I'd prefer it be inlined here and req not be a member. (It's referenced in ListObjectsV2Handler::operator() but it still doesn't need to be a member since the same ListObjectsV2Request is passed as an argument)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ListObjectsV2Handler::operator() gets the request as a const-ref, though. On the contrary, WalkChild doesn't have any need for the request object except to pass it to the handler.

Comment thread cpp/src/arrow/filesystem/s3fs.cc Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: this would be more readable if you rewrote as

Result<bool> DoHandle(... args);

void operator()(... args) {
  std::unique_lock<std::mutex> guard(walker->mutex_);
  auto maybe_truncated = DoHandle(args...);
  if (maybe_truncated.ok() && *maybe_truncated) {
    DCHECK(!result.GetNextContinuationToken().empty());
    req.SetContinuationToken(result.GetNextContinuationToken());
    walker->client_->ListObjectsV2Async(req, *this);
    return;
  }
  walker->ListObjectsFinished(std::move(maybetruncated).status());
}

Comment thread cpp/src/arrow/filesystem/s3fs.cc Outdated
Comment on lines 1387 to 1390

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since this is common to any recursive walk, should it be inlined in ListObjectsV2Handler::DoHandle or so?

Comment thread cpp/src/arrow/filesystem/s3fs.cc Resolved
Comment thread cpp/src/arrow/filesystem/s3fs.cc Resolved
Comment thread cpp/src/arrow/filesystem/s3fs.cc Resolved
Use the AWS SDK async APIs to launch child directory reads concurrently as soon
as we get the required information from a parent read.

Also, similarly issue directory tree deletion commands in parallel.

On this machine, listing the entire directory tree at "s3://mf-nwp-models/arome-france/v2/2020-12-02"
goes down from 12 seconds to 2 seconds (a 6x speedup).
@pitrou
pitrou force-pushed the ARROW-10788-s3-walk-async branch from f88fc45 to 9bf4cba Compare December 8, 2020 10:16
@pitrou pitrou closed this in d1b8ac0 Dec 8, 2020
@pitrou
pitrou deleted the ARROW-10788-s3-walk-async branch December 8, 2020 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants