Skip to content

Conversation

@wps132230
Copy link

Description of changes:
S3 CRT client is introduced with AWS SDK for C++ version 1.9, targeting high throughput for S3 GET and PUT operations, implemented on the top of AWS common runtime libraries.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Pushen Wang added 2 commits January 28, 2021 20:24
S3 CRT client is introduced with AWS SDK for C++ version 1.9, targeting high throughput for S3 GET and PUT operations, implemented on the top of AWS common runtime libraries.
Aws::String object_key = "my-object";
Aws::String region = Aws::Region::US_EAST_1;
double throughput_target_gbps = 5;
uint64_t part_size = 5 * 1024 * 1024; // 5 MB.
Copy link

Choose a reason for hiding this comment

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

Ryan was telling me that 8MB is a good default, and that's what's used in the C-API if a target throughput isn't specified.

I'm not sure if, in the C++ bindings, it's possible for the user to get a "default" part size

Copy link
Author

Choose a reason for hiding this comment

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

Aws::String bucket_name = "my-bucket";
Aws::String object_key = "my-object";
Aws::String region = Aws::Region::US_EAST_1;
double throughput_target_gbps = 5;
Copy link

Choose a reason for hiding this comment

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

I think they set the default bandwidth for CLI to be 25, might want to use that here too

Choose a reason for hiding this comment

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

I think they set the default bandwidth for CLI to be 25, might want to use that here too

Dengke saying that CLI is also 5Gbps

Copy link
Author

Choose a reason for hiding this comment

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

I will keep 5 Gbps here.

request.SetKey(objectKey);
auto bodyStream = Aws::MakeShared<Aws::StringStream>(ALLOCATION_TAG);
*bodyStream << "s3-crt-demo";
request.SetBody(bodyStream);
Copy link

Choose a reason for hiding this comment

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

[opinion] The existing s3 demo uploads a file from disk. That seems more interesting than uploading the string "s3-crt-demo"

@brmur brmur assigned ghost Feb 1, 2021
@brmur brmur added C++ labels Feb 1, 2021
@ghost ghost assigned wps132230 and unassigned ghost Feb 1, 2021
@wps132230
Copy link
Author

Updates:

  1. Use 8 MB as the part size in configuration.
  2. Upload a file instead of a stream.
  3. Add some cleanups in test code, and make sure Aws::ShutdownAPI(options); is called to avoid potential memory leak.
# Find the AWS SDK for C++ package.
find_package(AWSSDK REQUIRED COMPONENTS s3-crt)

# If the compiler is some version of Microsoft Visual C++, or another compiler simulating C++,

Choose a reason for hiding this comment

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

what you mean with "simulating c++"?

Copy link
Author

Choose a reason for hiding this comment

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

This file is copied from existing C++ SDK, I will make it more accurate.

#pragma warning (disable : 4503)
#endif // _MSC_VER

#if defined (_WIN32)

Choose a reason for hiding this comment

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

Why "if defined" here, but "ifdef" in the other lines?

Aws::S3Crt::Model::PutObjectRequest request;
request.SetBucket(bucketName);
request.SetKey(objectKey);
std::shared_ptr<Aws::IOStream> bodyStream = Aws::MakeShared<Aws::FStream>(ALLOCATION_TAG, fileName.c_str(), std::ios_base::in | std::ios_base::binary);

Choose a reason for hiding this comment

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

I didn't follow the whole flow for this, but at a first glance it doesn't look like you sharing the ownership of this object. Could it be a unique_ptr?

Copy link
Author

Choose a reason for hiding this comment

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

  1. SetBody() requires a shared pointer.
  2. It's a shared pointer because we pass this pointer down to the http client. For async call, it will be shared to that thread.
return Aws::MakeShared<Aws::Utils::Logging::DefaultCRTLogSystem>(ALLOCATION_TAG, Aws::Utils::Logging::LogLevel::Warn);
};

#if 0

Choose a reason for hiding this comment

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

if 0?

Copy link
Author

Choose a reason for hiding this comment

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

I could comment out those lines as well.

Choose a reason for hiding this comment

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

Why we release commented code?

Aws::String file_name = "my-file";
Aws::String region = Aws::Region::US_EAST_1;
double throughput_target_gbps = 5;
uint64_t part_size = 8 * 1024 * 1024; // 8 MB.

Choose a reason for hiding this comment

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

const?


Aws::String region = Aws::Region::US_EAST_1;
double throughput_target_gbps = 5;
uint64_t part_size = 5 * 1024 * 1024; // 5 MB.

Choose a reason for hiding this comment

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

const?

Aws::String file_name = "my-file-" + uuid + ".txt";

Aws::String region = Aws::Region::US_EAST_1;
double throughput_target_gbps = 5;

Choose a reason for hiding this comment

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

const?

@ghost ghost assigned brmur and unassigned wps132230 Feb 3, 2021
@ghost ghost removed the on review label Feb 3, 2021
brmur added 2 commits February 4, 2021 10:34
Branding guidelines specify that first mention of Amazon S3 is full version.
@brmur brmur merged commit fbb568b into awsdocs:master Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants