PERF: Refactor RelabelComponentImageFilter#1573
Conversation
f56a311 to
a21fc90
Compare
dzenanz
left a comment
There was a problem hiding this comment.
This already looks good. This filter should be noticeably faster now. Did you do any measurements, even if it is just counting the seconds it takes to process a large image?
I think that the first pass can be parallelized too. Have each thread compute its own sizeMap, and merge them as a reduction step. The map merge logic has been already employed in a few filters, introduced by you in label statistics filter (I think).
Modules/Segmentation/ConnectedComponents/include/itkRelabelComponentImageFilter.h
Show resolved
Hide resolved
Modules/Segmentation/ConnectedComponents/include/itkRelabelComponentImageFilter.hxx
Outdated
Show resolved
Hide resolved
a21fc90 to
6392779
Compare
dzenanz
left a comment
There was a problem hiding this comment.
Looks great!
How much slower is big_random than big_zero test?
|
I did performance testing on a 512^3 image of unsigned short pixels. The tests are included in the PR. Neither of them are "real world" images but represent two extreme cases. Here are the results:
old - the prior version The results are from a Mac Pro workstation with 8 core + HyperThreading. The new revision has performance improvement across the board even with single threads. The platform multithread has a 11x and 14x speed up vs the old single threaded implementation. The thread pool using 64 work units has more progress events than the old implementation which may account for some of the performance difference when compared to the platform threader. |
Parallelized the computation of the label counting with parallel reduction of the map. Parallelized applying the output production step. Modernizes the use of STL data structures and loops. Stream-lined cases. Save iterators used for searching to exploit coherence in images. Updated some type to avoid casts. The filter clearly maps input pixels to output pixels, so those type are used. And the number of objects type has been changed to SizeValueType.
6392779 to
234bbf3
Compare
zivy
left a comment
There was a problem hiding this comment.
Very nice work. Speedups always welcome.
Closed issues: CMake configure warning with CMake 3.30 and newer #1579 Merged pull requests: pkgconfig: drop unused libraries from Libs.private #1591 (bgilbert) Fix CMake warning: Compatibility with CMake < 3.10 will be removed #1580 (dzenanz) code documentation updates #1576 (weanti) Fixed ICC profile copy failure on write #1574 (mircomir) opj_jp2_read_header: Check for error after parsing header. #1573 (sebras) (CVE-2025-54874)
Parallelized applying the output production step. Modernizes the use
of STL data structures and loops. Stream-lined cases. Save iterators
used for searching to exploit coherence in images.
PR Checklist
Refer to the ITK Software Guide for
further development details if necessary.