Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing images is slow #2223

Open
Shnatsel opened this issue May 1, 2024 · 1 comment
Open

Resizing images is slow #2223

Shnatsel opened this issue May 1, 2024 · 1 comment

Comments

@Shnatsel
Copy link
Contributor

Shnatsel commented May 1, 2024

The image resizing routines in image seem to be really slow compared to the competition.

For example, fast_image_resize crate benchmarks show that image is 5x slower than libvips and fast_image_resize's fallback implementation, and 20x slower than fast_image_resize's AVX2 implementation. It also does runtime CPU feature detection.

I have run the RGB benchmarks locally against image v0.25.1 to reproduce the results, and I can confirm that they are accurate on my machine - the performance gap is real:

|            | Nearest |  Box  | Bilinear | Bicubic | Lanczos3 |
|------------|:-------:|:-----:|:--------:|:-------:|:--------:|
| image      |  21.10  |   -   |  61.47   | 103.41  |  145.23  |
| resize     |    -    | 21.92 |  43.90   |  81.38  |  120.40  |
| libvips    |  5.64   | 46.89 |  15.42   |  23.99  |  31.24   |
| fir rust   |  0.20   | 7.27  |  11.57   |  20.53  |  29.96   |
| fir sse4.1 |  0.20   | 3.23  |   4.52   |  7.91   |  11.45   |
| fir avx2   |  0.21   | 2.32  |   2.90   |  5.04   |   8.25   |
@Shnatsel
Copy link
Contributor Author

Shnatsel commented May 1, 2024

It's tempting to just use fast_image_resize - or at least its fallback implementation, and perhaps make all the unsafe SIMD intrinsics an opt-in feature like we did with rav1e and its nasm feature.

The drawback is that there seems to be some unsafe code in the fallback implementation that would need to be audited. Also, it seems the crate has never been fuzzed.

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

No branches or pull requests

1 participant