Skip to content

Improve ResizeProcessor performance #139

@antonfirsov

Description

@antonfirsov

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have searched open and closed issues to ensure it has not already been reported

Description

This issue has been opened to track and discuss perf improvements that could be made to ResizeProcessor:

  • Use PinnedBuffer<Vector4> for firstPassPixels and utilize bulk conversion
  • Apply microoptimizations to ResamplingWeightedProcessor<TColor>.Weights to make it more cache friendly

Investigate possibilities to reduce the size of resampler windows without loss of quality.

  • Operate on a transposed variant of firstPassPixels to utilize BulkPixelOperations<TColor>.PackFromVector4().
  • Drop repetitive weight values in WeightsBuffer
  • Use Value Type Kernels as Weights windows
  • Investigate possibilities for faster Compress and Expand execution to speedup the Compand variant.

Update

After analyzing the precomputed weights data, I found out the windows are much smaller than I thought (I misread the code first time), so we can not reduce the window size.

However:

  • This is how the WeightsBuffer looks like with a Bicubic 500->200 resize operation. 90% of the data is repetitive. We can allocate + precalculate less!
  • The size of IResampler.Radius is known at compile time for each reasmpler. It means we can achieve significant improvements by utilizing Value Type Kernels. (See Proposal: Value Type Kernels #142)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions