-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bug: Sam Local invoke has deliberate delay of 1s #6173
Comments
Thanks @andyfase for raising this issue. |
@moelasmar thanks for responding. I actually tried both Actually I now don't believe this is a arm vs x86 issue. Perhaps I didn't see this before on codebuild as the packaged version in codebuild is older? Anyway I believe I tracked this down to a deliberate 1 second sleep in the code which was introduced approx ~4 months ago. I've tested re-building locally commenting out this line and the impact on my test suite is dramatic, see log snippets below but I go from a test suite taking ~50 seconds down to one taking ~3 seconds. The sleep seemingly was added to ensure the payload of the lambda is outputted to I'll attempt to change the title of the BUG to reflect the actual issue. Output of testing: using sam from pip
Results in
using locally built sam with the 1 second sleep commented out
|
thanks @andyfase for the deep investigation. sorry for my misunderstanding, I thought that your problem related to difference between executing in linux X86 environment, and Mac Arm. I will check your suggested solution, and run our integration test cases to make sure that it will not break our logic. |
Is there any update on this? |
+1 any update on removing this deliberate delay? |
I've opened a pr #6418 that should address this issue, once it is merged it should be out in the next release |
Patch is released in v1.105.0. Closing |
Description:
I typically use SAM Local within a mocked integration test framework passing in a number of events using pytest. I mock dependencies using DynamoDB local or Moto so that a full test suite can be run - typically this involves 40-50 test invokes of different events. The entire environment is run within a number of docker containers within a docker network - with SAM, DDB Local and Moto all sitting in containers connected over a docker network.
Running this on a linux environment (or seemingly any x86 environment) this will typically take ~2 seconds to run, with each invoke being measured in < 50ms. I can see this when run within Codebuild for example.
However when run locally on my M1 Mac, the tests takes over 1 second each to run, making it non optimal for local development.
SAM version
Run using
Debug logs show
The event comes in "08:43:37,119", function invoked at "08:43:37,167" - which seemingly runs for 24.22ms. However the HTTP response to "functions/app/invocations" seems to occur almost 900ms after the lambda completes. If I add debug logging to my function and log when the response is given back out of the handler I can confirm the delay from the exit of the handler until the time of the HTTP payload is sent back from "functions/app/invocations"
Steps to reproduce:
As mentioned run "sam local start-lambda" on a M1 mac and notice the delay in a invoke coming in and the response being sent back on the HTTP response out of the SAM framework.
Observed result:
See above
Expected result:
The time for a given invoke to be a maximum of + 50ms above the actual time for the lambda code to complete.
Paste the output of
sam --info
hereThe text was updated successfully, but these errors were encountered: