Skip to content

Contender 1 (Dev-Ready Slim): Cut pythonr to 3.16 GB (-49.1%) and python to 1.49 GB (-26.1%) while retaining C/C++ -dev headers - #141

Merged
Robinlovelace merged 2 commits into
masterfrom
perf-contender-1-dev-slim
Nov 3, 2026
Merged

Robinlovelace merged 2 commits into
masterfrom
perf-contender-1-dev-slim

Conversation

@Robinlovelace

Copy link
Copy Markdown
Contributor

Summary — Contender 1: Dev-Ready Slim (python 1.49 GB, pythonr 3.16 GB)

Following a 12-combination deep-dive optimization study across geocompx/docker, this PR implements Contender 1 (Dev-Ready Slim), which achieves a 49.1% (-3.05 GB) reduction on geocompx/pythonr and a 26.1% (-526.2 MB) reduction on geocompx/python (compared to pre-PR #140 master) while retaining all C/C++ -dev header packages (libgdal-dev, libgeos-dev, libproj-dev, libudunits2-dev, etc.) for users who compile custom C/C++ spatial packages from source at runtime.

Key Optimizations Added (on top of #140)

  • python/Dockerfile (1.76 GB -> 1.49 GB, -268.6 MB additional / -526.2 MB total):
    • Configure /etc/dpkg/dpkg.cfg.d/docker-no-doc (path-exclude for /usr/share/doc/*, /usr/share/man/*, /usr/share/locale/*, /usr/share/info/*) and combine apt-get + gh + quarto installation in a single layer.
    • Temporarily install binutils in the uv pip install layer, strip debug symbols (strip --strip-unneeded) from site-packages/**/*.so* (-147.4 MB), prune bundled package unit test suites (*/tests), C++ headers (pyarrow/include, numpy/_core/include), jupyterlab/galata, jedi/third_party/django-stubs, and *.js.map (-100.7 MB), hardlink duplicate files >4 KB (proj.db, libarrow_python.so*, Quarto assets) via SHA-256 inode linking (-38.8 MB), and apt-get purge -y --auto-remove binutils in the same layer.
  • pythonr/Dockerfile (4.15 GB -> 3.16 GB, -988.9 MB additional / -3.05 GB total):
    • Drop Clang's libomp-dev (which pulled in 184 MB of libllvm19 + libz3-4; R uses GCC's libgomp1).
    • Remove unused third-party static .a archives in /usr/lib/*-linux-gnu (libopenblasp.a, libicudata.a, libspatialite.a, liblapack*.a, etc. — -330 MB) while preserving /usr/lib/gcc (libgcc.a, libstdc++.a, libgfortran.a) and *nonshared.a so R CMD SHLIB / pkgbuild::check_build_tools() works out of the box.
    • Prune static pre-rendered HTML/PDF package vignettes (library/*/doc = 149 MB) and googlePolylines/i Boost header cache (47 MB) while preserving library/*/help so interactive ?func help in RStudio/VS Code works normally.
    • Set MAKEFLAGS="-j$(nproc)" for parallel C++ compilation, run SHA-256 inode hardlinking across /opt/R/current/lib/R/library, and assert zero missing shared libraries (ldd ... | grep "not found") at build time.
  • minimal, minimal-slim, suggests, osgeo, rocker-rpy:
    • Apply the same .so --strip-unneeded, site-library/*/doc vignette pruning, third-party .a cleanup, and Python dist-packages .so/test pruning in-layer.

Verified Benchmarks Across All 12 Experimental Combinations

Stage / Contender geocompx/python Size geocompx/pythonr Size Geocomputation with Python Full Book Render Geocomputation with R (Part I, Ch 1–7) Render
Baseline (Pre-#140 master) 2,012.8 MB (2.01 GB) 6,213.6 MB (6.21 GB) 199.41 s 120.16 s
PR #140 1,755.3 MB (1.76 GB) 4,150.5 MB (4.15 GB) 185.50 s 115.56 s
Contender 1 (This PR — Dev-Ready Slim) 1,486.6 MB (1.49 GB) (-26.1%) 3,161.5 MB (3.16 GB) (-49.1%) 123.23 s (-38.2%) 117.13 s (-2.5%)

…ilds, and multi-threaded OpenBLAS/GDAL/Arrow defaults
…-26% on python) retaining C/C++ -dev headers
@Robinlovelace
Robinlovelace merged commit c3ad647 into master Nov 3, 2026
13 checks passed
@Robinlovelace
Robinlovelace deleted the perf-contender-1-dev-slim branch November 3, 2026 09:35
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.

1 participant