8000 WIP: Rewrite all image filters in Rust for improved performance and memory safety by marcelometal · Pull Request #1735 · thumbor/thumbor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WIP: Rewrite all image filters in Rust for improved performance and memory safety #1735

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcelometal
8000 Copy link
Member
@marcelometal marcelometal commented May 21, 2025

Summary

This PR replaces the entire image filter pipeline previously implemented in C with a new, high-performance Rust implementation leveraging the image crate for efficient per-pixel processing.
The Rust-based filters provide better performance and maintainability, and the legacy C code has been fully removed.

Additionally, Rust crates have been added for each filter under thumbor/ext/filters/_*, with CI support to run cargo check, clippy, and tests, ensuring code quality and stability.

Key Changes

  • 🦀 Rust Integration: Added initial Rust modules for filters and enabled Rust support via setuptools-rust. The build system now compiles Rust code alongside Python.
  • 🐳 Docker Images: Updated Dockerfiles to install the Rust toolchain, ensuring compatibility with Rust-based extensions during image builds.
  • 🧪 All Filters Rewrite: All filters were reimplemented in Rust. The previous Python implementation has been removed.
  • 🐍 Python Compatibility: Bumped the minimum supported Python version to 3.10, leveraging newer language features and simplifying compatibility maintenance.
  • 🧱 Architecture Support: Dropped support for i686 builds to reduce maintenance burden and focus on modern 64-bit systems.

Motivation

This change is part of an ongoing effort to migrate performance-critical components of Thumbor to Rust. Rust’s memory safety guarantees and low-level performance are a good match for image processing workloads. This initial step sets the stage for future filters to be rewritten or created directly in Rust.

Filters:

  • thumbor.ext.filters._alpha
  • thumbor.ext.filters._bounding_box
  • thumbor.ext.filters._brightness
  • thumbor.ext.filters._colorize
  • thumbor.ext.filters._composite
  • thumbor.ext.filters._contrast
  • thumbor.ext.filters._convolution
  • thumbor.ext.filters._curve
  • thumbor.ext.filters._equalize
  • thumbor.ext.filters._fill
  • thumbor.ext.filters._nine_patch
  • thumbor.ext.filters._noise
  • thumbor.ext.filters._rgb
  • thumbor.ext.filters._round_corner
  • thumbor.ext.filters._saturation
  • thumbor.ext.filters._sharpen

@marcelometal marcelometal force-pushed the convert_filters_to_rust branch 2 times, most recently from 09ab237 to 8257df9 Compare May 21, 2025 14:08
@coveralls
Copy link
coveralls commented May 21, 2025

Pull Request Test Coverage Report for Build 15600926369

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 89.07%

Files with Coverage Reduction New Missed Lines %
thumbor/filters/watermark.py 1 94.16%
Totals Coverage Status
Change from base Build 15598104058: -0.02%
Covered Lines: 3887
Relevant Lines: 4364

💛 - Coveralls

@marcelometal marcelometal force-pushed the convert_filters_to_rust branch 23 times, most recently from a269d1f to ca7ea29 < 8000 span class="Button-content"> Compare May 27, 2025 00:35
@marcelometal marcelometal changed the title WIP: Filters: Initial rust version WIP: Rewrite all image filters in Rust for improved performance and memory safety May 27, 2025
@marcelometal marcelometal force-pushed the convert_filters_to_rust branch 2 times, most recently from 6d97c99 to 36ac455 Compare May 27, 2025 01:19
@marcelometal marcelometal requested a review from scorphus May 27, 2025 01:20
@marcelometal marcelometal force-pushed the convert_filters_to_rust branch 2 times, most recently from 9077598 to dd69590 Compare June 5, 2025 14:09
@marcelometal marcelometal force-pushed the convert_filters_to_rust branch 5 times, most recently from 401e6c6 to 73a3772 Compare June 12, 2025 03:00
@marcelometal marcelometal force-pushed the convert_filters_to_rust branch from 73a3772 to c67f88c Compare June 12, 2025 03:30
Copy link

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.

2 participants
0