FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Optimize layer sizes by mnapoli · Pull Request #262 · brefphp/aws-lambda-layers · GitHub

Repository navigation

Optimize layer sizes - #262

Merged
mnapoli merged 2 commits into
v3from
optimize-layers
May 26, 2025
Merged

mnapoli merged 2 commits into
v3from
optimize-layers

Conversation

mnapoli commented May 26, 2025

Copy link
Copy Markdown
Member

The goal is to reduce layer sizes to optimize cold starts (that's the theory at least).

  • strip debug symbols for all libraries and PHP extensions (saves 11.7%)
  • compile PHP with the -Os C/CPP flag to optimize the binary for size (saves 8%)
  • compile libraries with the -Os flag (saves 6.3%)
  • disable the soap extension by default to avoid loading it on PHP startup (the only big unpopular extension I could find)
  • bundle the pdo-mysql extension in the PHP binary: it is extra small and will avoid loading it through an external file (small optimization)

In total that's a 24% size reduction, i.e. 14.6MB.

This is for Bref v3, I will run some benchmarks as just measuring the layer size doesn't tell us the full story about cold starts.

The goal is to reduce layer sizes to optimize cold starts (that's the theory at least).

- `strip` debug symbols for all libraries and PHP extensions (saves 11.7%)
- compile PHP with the `-Os` C/CPP flag to optimize the binary for size (saves 8%)
- compile libraries with the `-Os` flag (saves 6.3%)
- disable the `soap` extension by default to avoid loading it on PHP startup (the only big unpopular extension I could find)
- bundle the `pdo-mysql` extension in the PHP binary: it is extra small and will avoid loading it through an external file (small optimization)

In total that's a 24% size reduction, i.e. 14.6MB.

This is for Bref v3, I will run some benchmarks as just measuring the layer size doesn't tell us the full story about cold starts.
mnapoli mentioned this pull request May 26, 2025
3 tasks done

Copy link
Copy Markdown
Contributor

compile PHP with the -Os C/CPP flag to optimize the binary for size (saves 8%)

This could probably be backported to bref 2 without any issues.

mnapoli commented May 26, 2025 •
edited
Loading

Copy link
Copy Markdown
Member Author

Yes but there is some uncertainty on whether -Os is worth it over -O3 or even -O2 in terms of performance, so I'd feel much more comfortable being able to have a long beta period where multiple people can beta test these changes.

GrahamCampbell commented May 26, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

Ah, good point. -O1 or even -O2 are probably quite conservative options to go with in Bref 2, if we wanted.

Copy link
Copy Markdown
Contributor

Asking Claude what it thinks...

mnapoli commented May 26, 2025

Copy link
Copy Markdown
Member Author

I'll run some benchmarks and see if there is any noticeable change

mnapoli merged commit 2c97d8d into v3 May 26, 2025
mnapoli deleted the optimize-layers branch May 26, 2025 18:25
mnapoli mentioned this pull request May 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL