Repository navigation
Buffer API changes, Optimization and refactor of ResizeProcessors - #141
Conversation
Conflicts:
src/ImageSharp/Common/Memory/BufferPointer{T}.cs
Codecov Report
@@ Coverage Diff @@
## master #141 +/- ##
=========================================
+ Coverage 87.72% 87.83% +0.1%
=========================================
Files 455 463 +8
Lines 19789 20041 +252
Branches 1474 1478 +4
=========================================
+ Hits 17360 17603 +243
- Misses 2020 2032 +12
+ Partials 409 406 -3
Continue to review full report at Codecov.
|
|
I can't see anything thing in here that worries me. Looking good 👍 |
JimBobSquarePants
left a comment
There was a problem hiding this comment.
Looks great. I really like the way you've restructured the weights buffer!
Just to note, the reason for the duplication before was that the compand if inside the loop was actually a significant factor on performance within the resize algorithm. I don't know if that is still the case.
That output table you produced is very interesting.
| /// <param name="destinationSize">The size of the destination window</param> | ||
| public WeightsBuffer(int sourceSize, int destinationSize) | ||
| { | ||
| this.dataBuffer = new PinnedImageBuffer<float>(sourceSize, destinationSize); |
There was a problem hiding this comment.
Any reason for not using the static method CreateClean to generate the clean buffer?
There was a problem hiding this comment.
No it was occasional. Could be more readable with CreateClean().
There was a problem hiding this comment.
Cool. I would say so. Intent is really obviously then.
|
I think it's enough to move out if-s from the inner loop. We can benchmark a version where they are outside the outer loops, but I don't think it's worth the efforts. |
|
|
Buffer API changes, Optimization and refactor of ResizeProcessors
Prerequisites
Buffer API changes
BufferPointer<T>toBufferSpan<T>. It's API is very similar toSystem.Spannow.PinnedImageBuffer<T>: a specialization ofPinnedBuffer<T>that holds 2D area of data. It's very similar toPixelAccessor<T>, but the elements are not constrained to beIPixel<T>-s.IPinnedImageBuffer<T>interface for common functionalities ofPixelAcccessor<T>andPinnedImageBuffer<T>. (SeePinnedImageBufferExtensions)ResizeProcessor changes
WeightsWindowandWeightsBuffer)ResizeProcessorandCompandResizeProcessorBenchmarks results
CPU specs:
Processor=Intel(R) Core(TM) i7-4810MQ CPU 2.80GHz, ProcessorCount=8
(4 physical cores)
Before:
After:
A fully sequential version of "after" on the same machine (no Parallel.For-s at all):
Conclusion: considering that I have 4 physical cores, the
2.85/0.85 = 3.35parallel speedup is quite good on the Compand stuff. It means, we should find an efficient way to keep the parallelism for non-server users.