-
Notifications
You must be signed in to change notification settings - Fork 865
[S3] PutObject High Memory Usage #894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I realise I didn't add any statistics to my opening post. The test harness in the opening post uses this image and just uploads it 200 times via:-
Total .NET Allocations: 114MB And then if we drill down into one call to It looks like every call to Thanks, |
See aws#894 for detailed description
I made the change (indy-singh@008c5ff) locally and complied the required projects in release and re-ran my test harness:- Total .NET Allocations: 98MB And then if we drill down into one call to Thanks, |
This bug was fixed and released in AWSSDK.Core 3.3.21.19
Incidentally, aws-sdk-net/sdk/src/Services/S3/Custom/_bcl+coreclr+pcl/AmazonS3Client.Extensions.cs Line 81 in 37b2546
Thanks for fixing this bug. Closing. Cheers, |
HI Indy-Singh, System Configuration; --Srinu |
@rsrini83 I would update to the latest version of AWS Core and try again. |
Whilst under taking performance work centred around memory, we have discovered that this method:-
aws-sdk-net/sdk/src/Services/S3/Generated/_bcl45/AmazonS3Client.cs
Line 4421 in 9814e24
Causes LOH allocations as well as fragmentation. As we are uploading small sized images (many thousand times a day) we can't see why this should be the case. This was revealed by taking dumps of production servers and dumping out the byte arrays. The byte arrays in question contained
;chunk-signature=
with image data afterwards.Using dotTrace we have been able to narrow down the allocations to
ChunkedUploadWrapperStream
specifically the constructor:-aws-sdk-net/sdk/src/Core/Amazon.Runtime/Internal/Util/ChunkedUploadWrapperStream.cs
Line 73 in 9814e24
For every invocation of the constructor two byte arrays are created each having a minimum size of
131072
:-aws-sdk-net/sdk/src/Core/Amazon.Runtime/Internal/Util/ChunkedUploadWrapperStream.cs
Line 40 in 9814e24
The threshold for objects to go onto the LOH is 85,000 bytes. We believe this is the root cause of the problem we are experiencing.
Expected Behavior
That uploading small files doesn't cause LOH allocation and further on down the line fragmentation.
Current Behavior
Every time you upload an image to S3 two byte arrays are created with a minimum size of 131072. This is greater than the 85,000 threshold causing both byte arrays to be allocated directly to the LOH.
Possible Solution
There are a few possible solutions:-
DefaultChunkSize
so that consumers of the API can set it themselvesDefaultChunkSize
to a number that is by default lower than the LOH threshold. Microsoft use 81920 inStream
:- https://referencesource.microsoft.com/#mscorlib/system/io/stream.cs,50Steps to Reproduce (for bugs)
Context
Our platform provides an API in which our customers can send us images. We then transform and upload these images to S3. We receive many thousands of images per hour.
Your Environment
The text was updated successfully, but these errors were encountered: