Skip to content

fix: reduce Lambda layer size by building Arrow without ICU #3336

Open
bujjibabukatta wants to merge 1 commit into
aws:mainfrom
bujjibabukatta:fix/reduce-lambda-layer-size-icu
Open

fix: reduce Lambda layer size by building Arrow without ICU #3336
bujjibabukatta wants to merge 1 commit into
aws:mainfrom
bujjibabukatta:fix/reduce-lambda-layer-size-icu

Conversation

@bujjibabukatta
Copy link
Copy Markdown

Fix: Reduce Lambda layer size by building Arrow without ICU

Closes #3331

Problem

Arrow 22 links against libicu when it is present in the build environment. Dockerfile.al2023 was installing libicu via dnf, which caused the AL2023 Lambda layers (Python 3.12 / 3.13 / 3.14) to bundle three ICU shared libraries:

Library | Size -- | -- libicudata.so.67 | ~30 MB libicui18n.so.67 | ~4 MB libicuuc.so.67 | ~3 MB

This added ~37 MB to the unzipped layer size, pushing it past the 200 MB Lambda limit and breaking deployments that stack multiple layers. The AL2 Dockerfile (Python 3.9–3.11) never installed libicu, so those layers were unaffected and stayed at ~167 MB.

Changes

  • building/lambda/Dockerfile.al2023 — Remove libicu from the dnf install list so it is never present during the Arrow build.
  • building/lambda/build-lambda-layer.sh — Three changes:
    1. Add -DARROW_WITH_ICU=OFF to the Arrow cmake invocation to explicitly disable ICU support regardless of what is installed.
    2. Remove libicudata.so.67, libicui18n.so.67, and libicuuc.so.67 from the bundled .so copy loop (they are no longer needed).
    3. Run strip on all bundled lib/*.so files after copying to recover a few extra MB.

Result

Expected unzipped layer size after this fix: ~167 MB — back to pre-3.16.1 levels — unblocking users who stack multiple Lambda layers.

Testing

Built the AL2023 layer locally and confirmed:

  • libicudata.so.67, libicui18n.so.67, libicuuc.so.67 are no longer present in the zip.
  • pyarrow imports successfully and core functionality works without ICU.
  • Layer size is back within the 200 MB Lambda limit.
Fix: Reduce Lambda layer size by building Arrow without ICU Closes #3331

Problem
Arrow 22 links against libicu when it is present in the build environment. Dockerfile.al2023 was installing libicu via dnf, which caused the AL2023 Lambda layers (Python 3.12 / 3.13 / 3.14) to bundle three ICU shared libraries:

Library Size
libicudata.so.67 ~30 MB
libicui18n.so.67 ~4 MB
libicuuc.so.67 ~3 MB
This added ~37 MB to the unzipped layer size, pushing it past the 200 MB Lambda limit and breaking deployments that stack multiple layers. The AL2 Dockerfile (Python 3.9–3.11) never installed libicu, so those layers were unaffected and stayed at ~167 MB.

Changes
building/lambda/Dockerfile.al2023 — Remove libicu from the dnf install list so it is never present during the Arrow build.
building/lambda/build-lambda-layer.sh — Three changes:
Add -DARROW_WITH_ICU=OFF to the Arrow cmake invocation to explicitly disable ICU support regardless of what is installed.
Remove libicudata.so.67, libicui18n.so.67, and libicuuc.so.67 from the bundled .so copy loop (they are no longer needed).
Run strip on all bundled lib/*.so files after copying to recover a few extra MB.
Result
Expected unzipped layer size after this fix: ~167 MB — back to pre-3.16.1 levels — unblocking users who stack multiple Lambda layers.

Testing
Built the AL2023 layer locally and confirmed:

libicudata.so.67, libicui18n.so.67, libicuuc.so.67 are no longer present in the zip.
pyarrow imports successfully and core functionality works without ICU.
Layer size is back within the 200 MB Lambda limit.

Arrow 22 links against libicu when it is present in the build environment.
Dockerfile.al2023 was installing libicu, causing the AL2023 Lambda layers
(Python 3.12/3.13/3.14) to bundle libicudata.so.67 (~30 MB),
libicui18n.so.67, and libicuuc.so.67 - a ~37 MB increase that pushed the
unzipped layer past 200 MB and broke deployments that stack multiple layers.

The AL2 Dockerfile (Python 3.9-3.11) never installed libicu, so Arrow 22
already compiled without it there and those layers stayed at ~167 MB.

Fix:
- Remove libicu from Dockerfile.al2023 dnf install.
- Add -DARROW_WITH_ICU=OFF to the Arrow cmake invocation.
- Drop libicudata.so.67, libicui18n.so.67, libicuuc.so.67 from the bundle loop.
- Strip the bundled lib/*.so files to recover a few extra MB.

Expected layer size after this fix: ~167 MB (back to pre-3.16.1 levels).

Co-Authored-By: Bujji Babu Katta & Srihari Ponakala
@bujjibabukatta
Copy link
Copy Markdown
Author

Hi @dheerajinampudi , Could you please verify and merge pull request ? Thanks

@kukushking
Copy link
Copy Markdown
Collaborator

Hi @bujjibabukatta looks good, thank you for handling this!

echo "WARNING: ${libfile} not found on this image"
fi
done
find lib -name '*.so*' -type f -exec strip "{}" \;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warrants a small comment: strips the symbol tables / debug info from the binaries.

@bujjibabukatta
Copy link
Copy Markdown
Author

Hi @cournape could you please approve?

@bujjibabukatta
Copy link
Copy Markdown
Author

bujjibabukatta commented May 25, 2026

Hi @jaidisido @kailukowiak could you please approve?

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.

Stark increase in layer size with version 3.16.1 causing Lambda deployment failures

4 participants