-
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
"sam build" feedback: Support incremental builds #805
Comments
For python builds, our internal build tool creates a MD5 of the Here's the steps that our build tool takes to avoid running
You could maybe store the requirements.txt MD5 under |
Could you maybe post this source code (even though the instructions are helpful) |
Where do we stand on this one? Would love to see this supported for rapid development and iteration. ping @sanathkr |
@ranman This is a good feature to have, but hard to support across all programming languages. We could probably start with @billyshambrook's suggestion is a good one and can be implemented fairly easily in the Python build workflow (https://github.com/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/python_pip/workflow.py#L67). It would be more valuable, if we can get some design thinking around support this across programming language. There are several levels of incremental build we can support:
For each of the cases above, we need a different mechanism to know when to rebuild. It would be great if someone can do the thinking and submit a design document PR. This will really help move this forward. References
|
The other way I have done this is by utilizing docker, and create a docker image for the build. This way you can use docker layer cache. I have found its also a workaround if you don't have the ability to mount volumes like in some CI tools, as you are just using COPY. However this is a bigger change, and requires to always use docker to build. This would then make it easier to support cross language. |
I've created a Makefile with a .PHONY target Seems to work for me. I'm happy to hear feedback. https://gist.github.com/jghaines/5b5b2530bf21b0a1adab3f6683aa7af5 |
we're currently getting frustrated with the sam build process, it only gets worse overtime. we had to go thru waiting, wasting 10-15 minutes per build. so if were going to have 5-6 builds for each change we have (even if its a single line), we had to go thru the entire process of the sam build and re-download all python dependencies all the time |
(SAMPIC attempts to do something similar to this.) |
Hey guys, So, we created a small npm package based in nodemon (samwatch): https://www.npmjs.com/package/samwatch https://github.com/mxitgo/samwatch The way it works is, it copies your js/json files as you save them from the source folder to the corresponding .aws-sam/build folder (as long as the names are the same for your lambda and the code uri in template.yaml). That is useful to see your changes reflected on the fly if you are running sam local start-api, so you don't have to run sam build after every change. On the other hand, if the corresponding file copy is not within the .aws-sam/build folder already, the package will trigger a sam build (unless you use n parameter). The package has helped us get a hot reload feeling for our local lambda function development with sam. I hope anyone can find it useful. Thanks! |
Here's another perspective. I'm using node.js, but the issue appears to be the same. The key issue is how long it takes every time a developer makes a single code change and wants to run and test it. Here is a simple way to reproduce the issue:
The sample project is set up. Each build takes over 30 seconds. There are 3 lambda functions in this sample project. It builds and copies everything every time a developer makes a change and wants to test it. This build time only continues to increase as you add more to the project. When it builds, it copies everything into each build every time for every lambda function whether it was changed or not:
So for a simple node.js 'hello world' function, over 50 MB is copied into each function. When the project is deployed to aws lambda, each lambda function is so large that you can't see the code for the lambda function once it's deployed. It also appears to be slower to run as the deployment is so large and needs to be loaded first. In the process above, these are just the defaults that ship with sam (which could possibly be improved to reduce the deployment size). Each project has different needs, and in an effort to improve this for my project I wasn't able to find any documentation that shows how to control sam build to include only the required files. Here are some observations:
Here are suggestions:
I hope this helps! I believe that a faster development cycle would help reduce developer frustration and increase adoption for aws sam. |
My ScenarioI'm writing a ruby lambda, and wanted to test is via Attempts to work around the issue with existing solutionsI'm going to give @eamarce plugin a try. [update] I guess that is only for javascript based projects.... Attempt to work around the issueI only have a single function right now. As far as I understand, I just need to move code changes into the 🤔 Question: If I am running
|
|
SAM incremental build feature is out in Beta! Run To learn more about Sam Accelerate, check out the blog here and the video here. |
@praneetap that's awesome that the team has launched this feature. I think the sam experience has been great but the build times have been a major pain point. By the way the blog article you linked doesn't mention you have to pass the Anything on the roadmap to speed up |
i would love to hear the specific issues you have with deploy! Is it just the time taken? We recommend using SAM sync during development phase, which has faster deployment times, and using SAM deploy in your pipelines. |
Thank you @praneetap I was not aware of the Still I will check this out. My main issue with Maybe Two items I'd like to see that I think would be really helpful for local development: I'm happy to go into detail on any of the items mentioned or forward other suggestions. I didn't want to derail so I stuck to sam build / deploy items above but I also have issues with testing changes locally which require events triggered from Dynamo Streams/SQS. Thank you and team for sam accelerate. I think this is a great thing for aws development. |
@ahurlburt yes, that’s exactly what ‘—code’ does! Happy to get on a call to chat about the other features in your feedback, please DM me to set up a time |
Hello! Happy to announce that SAM Accelerate (which includes incremental build with a watch option) is now in GA. Please try this feature out and let us know if you have any feedback. |
Description:
sam build
does a clean build every time. This can slow down the local dev-test loop because it will be downloading and installing dependencies on each build.An incremental build will only reinstall dependencices when your dependency manifest changes and copy only relevant pieces of code that changed. So you can get a really fast dev-test cycle locally without compromising on the build capabilities. This could be implemented as a
sam build --watch
which will watch files for changes and perform an incremental build.The text was updated successfully, but these errors were encountered: