Skip to content
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

s3ng: Provide objectSize when uploading to reduce memory usage #1940

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

AndreasSko
Copy link
Contributor

According to the documentation for PutObject, setting objectSize to -1 causes a multipart Put operation until the input stream reaches EOF, which can result in high memory usage. Something similar has already been reported in minio/minio-go#1496

This PR changes the behavior so it tries to determine the file size before uploading it. Should the given io.Reader not be a file, it falls back to using -1.

In my testing this change has reduced the memory usage when uploading files to OICS quite a bit: From over 1GB for a single user, down to <300MB.

Closes #1933

@AndreasSko AndreasSko requested a review from labkode as a code owner July 30, 2021 15:35
According to the documentation for `PutObject`,
setting objectSize to -1 causes a multipart Put
operation until the input stream reaches EOF,
which can result in high memory usage.
Something similar has already been reported in
minio/minio-go#1496

This PR changes the behavior so it tries to determine
the file size before uploading it. Should the given
io.Reader not be a file, it falls back to using `-1`.

In my testing this change has reduced the memory
usage when uploading files to OICS quite a bit:
From over 1GB for a
single user, down to <300MB.
@labkode labkode merged commit 3c034f9 into cs3org:master Aug 2, 2021
@labkode
Copy link
Member

labkode commented Aug 2, 2021

Thanks @AndreasSko for this nice fix!

@AndreasSko AndreasSko deleted the fix_high_mem_usage_s3 branch August 2, 2021 06:29
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.

Provide objectSize for S3 upload to reduce memory usage
2 participants