-
Notifications
You must be signed in to change notification settings - Fork 402
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
docs(install): instructions to reduce pydantic package size #1077
docs(install): instructions to reduce pydantic package size #1077
Conversation
Pydantic can be installed without binary files. This significantly reduces the additional size it adds to the compressed Lambda packages (down to 2MB from 25MB) at the expense of 30%-50% of its performance. While at it I also updated the amount of megabyte Pydantic adds to the package, as it wasn't clear if the stated number referred to compressed or uncompressed package size and I couldn't reproduce the 75MB either way.
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
Codecov Report
@@ Coverage Diff @@
## develop #1077 +/- ##
========================================
Coverage 99.96% 99.96%
========================================
Files 119 119
Lines 5373 5376 +3
Branches 613 613
========================================
+ Hits 5371 5374 +3
Partials 2 2
Continue to review full report at Codecov.
|
Hey @Dunedan thanks a lot for this! I've just edited your description to refer to an existing issue about the new option - the MB size was uncompressed when we tried back when Parser feature was added (+1 year). We're currently prioritizing bugs only given our bandwidth, so we might have delays to review, reproduce, and get this merged. @am29d it'd be great to have this tested and automatically included in our Lambda Layer and SAR App so customers don't have to. |
Hey @Dunedan thanks for the contribution! I have compared both installations uncompressed, and the difference is 9,8MB, which is more than 10% packages size improvement (88MB vs 79MB). Overall I was surprised that our package size for extras went down to 88MB. The docs still says 22mb (compressed) 155mb (uncompressed). Can we also update this detail to 12MB and 79MB? |
@am29d What's the "installations" you compare? I believe I do something different, as the sizes I get are completely different ones:
|
Interesting, I use
Here is the result of the folders and zip files:
In your case, even if we substract the venv size from the module installation, there still remains something there that is much bigger. Now I am curious if we miss anything in our layer, that we did not discovered yet 🤔. EDIT: I wanted to rule out OSX dependency and ran the same test on AL2, and the results are weirdly different:
|
Yes, of course, that makes sense.
Ah, so you ran it once on macOS and once on arm64, while I ran it on Linux running on amd64. That explains the differences, as the size of binary files (in this case the ones shipped with pydantic) differ between operating systems and CPU architectures. Here are my sizes using
So how to proceed here? As the actual Lambda package size also depends on other factors like the compression ratio or size differences between different versions of AWS Lambda Powertools and pydantic, I'm not sure if absolute values in the documentation will ever be accurate. What about a more fuzzy statement like:
|
Sorry, I implied you used AL2 with arm64, which of course doesn't have to be the case. |
This is good 👍. |
Alex, could we update SAR Extras App as part of this change so everyone
benefits from the smaller package size?
…On Thu, 24 Mar 2022 at 15:16, Alexander Melnyk ***@***.***> wrote:
What about a more fuzzy statement like:
This will increase the compressed package size by >10MB due to the
Pydantic dependency.
This is good 👍.
—
Reply to this email directly, view it on GitHub
<#1077 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBFC2YVVKLGEKMKD6QLVBR2KXANCNFSM5Q32JS2Q>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Yep, the SAR pipeline is not public, thus the new package size will be rolled out with the next release. |
I updated the statement about the package size now. There are still the outdated sizes for the Lambda layer in the documentation, however as its build scripts aren't public, I'm not sure how the sizes look now. Feel free to update those numbers as well before merging. |
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
thank you so much for this @Dunedan ! |
I managed to shrink an overly large $ cat requirements.txt
pydantic<1.9,>=1.7
$
$ mkdir -p src
$
$ python3 -m pip install -r requirements.txt -t ./src
...
$
$ du -sh src/pydantic
91M src/pydantic
$
$ strip src/pydantic/*so
$
$ du -sh src/pydantic
6.8M src/pydantic
$ Context:
|
Issue, if available: #1078
Pydantic can be installed without binary files. This significantly
reduces the additional size it adds to the compressed Lambda packages
(down to 2MB from 25MB) at the expense of 30%-50% of its performance.
While at it I also updated the amount of megabyte Pydantic adds to the
package, as it wasn't clear if the stated number referred to compressed
or uncompressed package size and I couldn't reproduce the 75MB either
way.
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
View rendered docs/utilities/parser.md