PERF: Use Boost.SmallVec in BCO interpolator
Summary
Use a small vector container for the output pixel and interpolator coefficients in BCOInterpolateImageFunction.
Rationale
This avoids two (for scalar images) or three (for vector ones) for small interpolation radii and number of bands.
before:
286.76user 5.17system 0:36.00elapsed 810%CPU (0avgtext+0avgdata 1013876maxresident)k
2288inputs+15071432outputs (5major+1442780minor)pagefaults 0swaps
290.62user 5.28system 0:34.09elapsed 867%CPU (0avgtext+0avgdata 1013312maxresident)k
35776inputs+15071432outputs (207major+1443014minor)pagefaults 0swaps
291.82user 5.01system 0:34.05elapsed 871%CPU (0avgtext+0avgdata 1013196maxresident)k
18960inputs+15071432outputs (133major+1443078minor)pagefaults 0swaps
after:
260.86user 5.44system 0:37.12elapsed 717%CPU (0avgtext+0avgdata 1013652maxresident)k
4272inputs+15071432outputs (3major+1443217minor)pagefaults 0swaps
257.90user 5.85system 0:38.22elapsed 690%CPU (0avgtext+0avgdata 1014272maxresident)k
8inputs+15071432outputs (1major+1443207minor)pagefaults 0swaps
261.12user 5.58system 0:36.90elapsed 722%CPU (0avgtext+0avgdata 1012968maxresident)k
0inputs+15071432outputs (0major+1443212minor)pagefaults 0swaps
Tested on Ubuntu 18.04. I expect it might make a larger difference on older systems, because the GLIBC memory allocator used to be very slow (it got a per-thread cache in 2.26).
Implementation Details
I'm not sure what's the minimum Boost version we support, so I left in a path for pre-1.58, where small_vector is not available.
Additional notes
This is technically a breaking change:
- the
BCOInterpolateImageFunctionBase::CoefContainertype is public and its type has changed -
BCOInterpolateImageFunctionBase::EvaluateCoefis no longer virtual
Copyright
The copyright owner is Laurențiu Nicola / CS ROMANIA and has signed the ORFEO ToolBox Contributor License Agreement.
Check before merging:
- All discussions are resolved
- At least 2
👍 votes from core developers, no👎 vote. - The feature branch is (reasonably) up-to-date with the base branch
- Dashboard is green
- Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
- Optionally, run
git diff develop... -U0 --no-color | clang-format-diff.py -p1 -ion latest changes and commit
Edited by Laurențiu Nicola