-
Notifications
You must be signed in to change notification settings - Fork 569
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
feat(lib-storage): improve performance by reducing expensive buffer concat operations #1955
Conversation
I don't have to dig deeper (yet), but replacing this with my last build (that I tested #1841 with) gave me the following error:
Happened with both |
@samsullivan yeah make sure you update everything to 3.3.0. I had the same issue... |
Ah, should've been able to figure that out on my own. Looks like it's working now. Thanks! I didn't have any more robust performance testing; however, this seems to be more thought out of a fix than my "bolt it on" approach in #1841 so I'm fine with this one being merged instead. Bummer that v2 SDK still had better performance here, but...the current v3 implementation is unusable. |
I have prepared another PR that will improve upload speeds further, even beating v2. It's a little more invasive by allowing passing Buffer arrays all the way down to the http-client and signer. I'll submit it if this PR gets merged. |
Codecov Report
@@ Coverage Diff @@
## master #1955 +/- ##
==========================================
+ Coverage 79.30% 79.85% +0.54%
==========================================
Files 368 368
Lines 15132 15544 +412
Branches 3222 3367 +145
==========================================
+ Hits 12001 12412 +411
- Misses 3131 3132 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍 Huge thanks to this optimization and the test case. It looks good to me!
The formating of the code is a little off. The Prettier should've formatted it but for some reason it doesn't seem the case. Can you try format the code?
@AllanZhengYP for some reason the pre-commit hook didn't run. Should be fixed now. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Issue #1841
Description of changes:
The
for await
syntax reads chunks from a readable stream and is in my opinion more concise and less error prone as NodeJS will take care of event handlers, exception handling, etc.In addition,
Buffer.concat
will only be called once per chunk which greatly improves performance (uploading a 1GB file would take 23 seconds previously, down to 10 seconds with this patch). The use ofBuffer.slice
is intentional as it does not copy or create a new buffer. Instead, it's basically a view into the buffer it slices over.I ran a few profiling runs over the code and I think there is more room for improvement. V2 of the SDK still seems to be ~20 percent faster. For example, v3 calls
update
frominternal/crypto/hash.js
twice as many times as v2.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.