Skip to content

Reduce monomorphization in fast_image_resize - #22

Draft
bgw wants to merge 1 commit into
mainfrom
bgw/fast-image-resize-reduce-monomorphization
Draft

bgw wants to merge 1 commit into
mainfrom
bgw/fast-image-resize-reduce-monomorphization

Conversation

@bgw

@bgw bgw commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Switches fast_image_resize to a git dependency on bgw/fast_image_resize@reduce-monomorphization (pinned to 627585f), which reduces monomorphization, to measure (and hopefully keep) the binary size savings.

Binary size (linux-arm64)

cargo build --package=nsio-worker --release --target=aarch64-unknown-linux-gnu (the release profile: LTO, 1 CGU, stripped), Rust 1.99.0, built natively on an aarch64 Linux host (not cargo-zigbuild like CI, so the absolute numbers may differ slightly from the published binary).

ELF segments on aarch64 are aligned to 64 KiB, so the linker pads the file between the R+X and RW LOAD segments. That padding is 64,400 bytes before and 41,704 bytes after, which makes the file-size difference look like exactly 3 × 64 KiB. "Without padding" subtracts that gap from the file size.

Before After Change
File size (with padding) 5,389,384 5,192,776 −196,608 (−3.65%)
Without padding 5,324,984 5,151,072 −173,912 (−3.27%)

By section:

Section Before After Change
.text 3,961,232 3,801,008 −160,224 (−4.0%)
.eh_frame 256,804 244,884 −11,920
.eh_frame_hdr 36,660 35,372 −1,288
.rodata 715,484 714,972 −512
everything else 0

Notes

  • Draft, because it depends on an unreleased fork. Ideally these changes land upstream and we go back to a crates.io release.
  • cargo test -p nsio-core passes locally; the e2e parity tests against sharp are left to CI.

🤖 Generated with Claude Code

Measured on linux-arm64 (aarch64-unknown-linux-gnu, release): the worker's
.text shrinks by 160 KB, and the binary by 174 KB (3.3%) excluding padding.

Co-Authored-By: Claude <noreply@anthropic.com>
@bgw bgw changed the title Use fast_image_resize's reduce-monomorphization fork Reduce monomorphization in fast_image_resize Nov 20, 2026

This branch has not been deployed

No deployments
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