Skip to content

Improve ResizeProcessor performance #139

Closed

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)

Activity

  1. self-assigned this
    on Mar 17, 2017
  2. antonfirsov commented on Mar 21, 2017

    @antonfirsov
    MemberAuthor

    Completed the first 2 points in #141 resulting in a 30% drop in execution time. Switching to a Vector4 -based pixeltype could bring in additional 10% or more for the non-compand case because of the faster bulk-conversions.

    I'm not planning to touch the others before the beta. Anyone who has interest: feel free to contribute or write your suggestions :)

  3. JimBobSquarePants commented on Mar 22, 2017

    @JimBobSquarePants
    Member

    Thanks for working on this. It's great improvement. 💯

  4. removed their assignment
    on Mar 30, 2017
  5. JimBobSquarePants commented on Apr 26, 2019

    @JimBobSquarePants
    Member

    Closing. We've come a long way since this was opened. And with #888 we've dramatically reduced memory pressure.

    Any further changes can be opened as individual issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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