winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.73k stars 185 forks source link

chore(sdk): updating the aws-sdk to version 3.577.0 #5611

Closed marciocadev closed 1 month ago

marciocadev commented 4 months ago

This PR updates the aws-sdk past version 3.502, which reduces the cold start runtime on Lambdas according to the article by David Behroozi: Coldstarts with the AWS Javascript 3.502 SDK

I did some tests and in a simple code like the one below, I managed to reduce the cold start from an average of 340ms to an average of 280ms (it's not much but every millisecond counts).

bring cloud;

let counter = new cloud.Counter() as "my-counter";

new cloud.Function(inflight () => {
  counter.inc();
}) as "my-function";

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

staycoolcall911 commented 4 months ago

Hey @marciocadev - what's the status of this PR? Once it's ready for review please let me know and move it out of draft, thank you

marciocadev commented 4 months ago

Hey @staycoolcall911

I'm having an issue with the getSignedUrl test, the aws-sdk is a bit tricky to mock and spyOn

marciocadev commented 4 months ago

@staycoolcall911, I need some help here.

Everything is okay, but the signedUrl test isn't working because I can't mock the getSignedUrl method. I created a project to test by copying this method, and the test I'm using in my project works perfectly.

I'm not able to get this to work, could someone help me with this?

Here's the project with the test working

https://github.com/marciocadev/AWSSignedUrlTest

staycoolcall911 commented 4 months ago

Hey @marciocadev - of course, I'll find someone to help you out.

staycoolcall911 commented 3 months ago

@marciocadev - @hasanaburayyan will reach out soon.

hasanaburayyan commented 3 months ago

@marciocadev my bad, I for some reason thought https://github.com/winglang/wing/pull/5429 included this change. But I see it only upgraded the sdk to 3.490.0

Chriscbr commented 3 months ago

I tried a few approaches (like mocks and spies) within our repo and also got stuck. After seeing it worked in https://github.com/marciocadev/AWSSignedUrlTest, I decided to instead try removing code from our repo to see what was necessary to get it working.

I'm not quite sure why it fixes it, but if I comment out this line in our vitest config, it seems to fix the test. cc @MarkMcCulloh https://github.com/winglang/wing/blob/845360a7877629185cac62ac9464b21a91c12608/libs/wingsdk/vitest.config.mts#L5

Chriscbr commented 1 month ago

@marciocadev @hasanaburayyan I feel for now it's better if we upgrade to the latest AWS SDK version and try to address the test mocking issue another time. I've pushed a commit that skips the relevant tests - let's try and get this across the finish line

Chriscbr commented 1 month ago

Spec tests passed: https://github.com/winglang/wing/actions/runs/9133888270

mergify[bot] commented 1 month ago

Thanks for contributing, @marciocadev! This PR will now be added to the merge queue, or immediately merged if update-aws-sdk is up-to-date with main and the queue is empty.

monadabot commented 1 month ago

Congrats! :rocket: This was released in Wing 0.73.53.