Skip to content

Conversation

@Sergio0694
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

The previous implementation of the BokehBlurProcessor<TPixel> was using a static ConcurrentDictionary<BokehBlurParameters, BokehBlurKernelData> field to store the preprocessed bokeh blur kernels for a pair of input parameters. The issue was that that static field was inside a generic class, meaning each concrete <TPixel> instantiation would've seen a completely different dictionary. As a result, running the same bokeh blur effect on multiple images of different pixel formats, even with the same parameters, would've caused the kernels to be recomputed every time, and stored separately in each dictionary, despite the kernels actually being exactly the same (they're not dependent on the pixel type they'll be used on).

This PR moves all the kernel preprocessing logic into a separate non-generic class, to solve the issues described above. I've also removed some unnecessary fields from the BokehBlurProcessor<TPixel> class, so that should also save a few bytes every time a new processor instance is created. 🚀

@codecov
Copy link

codecov bot commented Feb 14, 2020

Codecov Report

Merging #1113 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1113      +/-   ##
==========================================
+ Coverage      82%   82.02%   +0.01%     
==========================================
  Files         700      701       +1     
  Lines       28797    28797              
  Branches     3281     3281              
==========================================
+ Hits        23616    23621       +5     
+ Misses       4498     4494       -4     
+ Partials      683      682       -1
Flag Coverage Δ
#unittests 82.02% <100%> (+0.01%) ⬆️
Impacted Files Coverage Δ
...sors/Convolution/Parameters/BokehBlurKernelData.cs 100% <ø> (ø) ⬆️
...volution/Parameters/BokehBlurKernelDataProvider.cs 100% <100%> (ø)
...ocessors/Convolution/BokehBlurProcessor{TPixel}.cs 99.03% <100%> (+1.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f975498...7c02cc4. Read the comment docs.

@JimBobSquarePants JimBobSquarePants merged commit dfa34e9 into master Feb 18, 2020
@JimBobSquarePants JimBobSquarePants deleted the sp/bokeh-blur-cache-optimization branch February 18, 2020 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants