Repository navigation
Conversation
…orphization and code size
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for this library! We've been using it in https://github.com/vercel-labs/next-safe-image-optimization (which we want to start using in Next.js very soon).
I've been trying to reduce binary size with insights gathered via https://github.com/Boshen/cargo-bsize, and I discovered that the combination of
TypedImageandTypedImageRefinfast_image_resizecan lead to a bunch of wasted binary size.It's very easy to convert a
TypedImageto aTypedImageRef, andTypedImageRefshouldn't be any slower to resize, so we should always do the conversion when possible. This reduces the amount of monomorphization work the compiler does.Some real-world numbers for aarch64 linux here: vercel-labs/next-safe-image-optimization#22
If you're interested, I think there's some similar improvements that could be done for the cropped image representations, but it seemed possibly a little more involved, and this PR seemed like a good first step.
AI Disclaimer
I don't know what your desired contribution policy for this repository is.
I used Claude Code with Opus 5.5 to write the code, though this was not the first approach it suggested. The first was involved inverting a loop, modified every convolution implementation (a huge diff), and added extra branching for every row of pixels (likely a couple % perf hit).
I rewrote all the comments to be clearer, and carefully reviewed the diff before submission. This PR description is hand-written.