Skip to content

Reduce Linux wheel size below 25 MB #107

Description

@shimwell

Summary

The Linux manylinux wheel built on the making-wheel-3 branch (PR #70) is 31.4 MB compressed (104.8 MB unpacked). This documents where the size goes and three concrete, low-risk levers to bring it under 25 MB.

Measured from openmc-0.15.3-cp312-cp312-manylinux_2_28_x86_64.whl (run 28036782175, commit e591c09).

Where the size goes (top contributors, compressed)

File Compressed Unpacked Stripped?
libembree4.so.4 16.13 MB 46.60 MB ❌ not stripped
libMOAB.so.5.5.0 3.09 MB 16.10 MB ❌ not stripped
libhdf5.so 2.80 MB 10.39 MB ❌ not stripped
libnetcdf.so.22 1.52 MB 4.69 MB ❌ not stripped
libopenmc.so 1.35 MB 3.66 MB ✅ stripped
curl/TLS/DAP chain (21 libs) 4.20 MB ✅ mostly stripped

libopenmc.so and most direct deps are already stripped; the large bundled dependencies (Embree, MOAB, HDF5, netCDF) are not.

Three levers (need to cut > 6.4 MB)

1. Build Embree with fewer ISA variants — saves ~7–8 MB

tools/ci/cibw_before_all_linux.sh builds Embree v4.3.3 with all ISA kernels compiled in (SSE2, SSE4.2, AVX, AVX2, AVX-512). That is the bulk of the 16 MB — it is machine code, not debug info, so stripping does not help it.

Building only the ISAs we actually need roughly halves Embree. Suggested cmake flags (keeps the AVX-512 fast path and an AVX2 fallback for non-AVX-512 CPUs):

-DEMBREE_ISA_SSE2=OFF
-DEMBREE_ISA_SSE42=OFF   # (optionally keep =ON for pre-2013/no-AVX2 CPUs)
-DEMBREE_ISA_AVX=OFF
-DEMBREE_ISA_AVX2=ON
-DEMBREE_ISA_AVX512=ON

Tradeoff: AVX2+AVX-512 only drops support for pre-2013 (no-AVX2) CPUs in the ray tracer. Keeping EMBREE_ISA_SSE42=ON (3 ISAs) retains broad CPU support and still saves a large chunk.

2. Build netCDF without DAP — saves 4.2 MB (removes 21 libs)

tools/ci/cibw_before_all_linux.sh builds netCDF with -DENABLE_DAP=ON, which pulls in libcurl and its entire transitive TLS stack (libcrypto, libssl, libssh, libkrb5, libldap, libsasl2, libnghttp2, libidn2, libpsl, brotli, …) — 21 libraries totaling 4.20 MB compressed that auditwheel then bundles. OpenMC reads local mesh/HDF5 files only and never uses netCDF's remote (HTTP/DAP) access.

-DENABLE_DAP=OFF

3. Strip bundled libraries — saves ~2.2 MB

The auditwheel repair command in pyproject.toml does not strip:

repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}"

Add --strip so the un-stripped Embree/MOAB/HDF5/netCDF symbol tables are removed:

repair-wheel-command = "auditwheel repair --strip -w {dest_dir} {wheel}"

Expected result

Applied Approx. wheel size
Today 31.4 MB
#3 strip only ~29 MB
#2 + #3 ~25 MB (on the edge)
#1 + #2 + #3 ~18 MB

Levers #2 and #3 are zero-tradeoff. Lever #1 is the decisive one and aligns with the AVX-512 portability goal of the branch (AVX2 = the "without AVX-512" path, AVX-512 = the fast path).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions