Skip to content

PERF: Refactor RelabelComponentImageFilter#1573

Merged
blowekamp merged 1 commit intoInsightSoftwareConsortium:masterfrom
blowekamp:RefactorRelabelComponentImageFilter
Jan 27, 2020
Merged

PERF: Refactor RelabelComponentImageFilter#1573
blowekamp merged 1 commit intoInsightSoftwareConsortium:masterfrom
blowekamp:RefactorRelabelComponentImageFilter

Conversation

@blowekamp
Copy link
Member

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.

@blowekamp blowekamp force-pushed the RefactorRelabelComponentImageFilter branch from f56a311 to a21fc90 Compare January 23, 2020 14:45
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@blowekamp blowekamp force-pushed the RefactorRelabelComponentImageFilter branch from a21fc90 to 6392779 Compare January 24, 2020 21:12
@blowekamp blowekamp marked this pull request as ready for review January 24, 2020 21:15
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

How much slower is big_random than big_zero test?

@blowekamp
Copy link
Member Author

blowekamp commented Jan 24, 2020

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 old - no progress pool 1/1 pool 16/64 platform 16
zeros 1.41s 0.5s 0.3s 0.15s 0.098s
random 37.1s 35s 27s 3.5s 3.28s

old - the prior version
old - no progress* - the prior version with CompetePixel commented out
pool 1/1 - the pool multithread with just one thread
pool 16/64 - the pool multithreaded with 16 threads and 64 work units
platform 16 - the platform multithreaded with 16 threads

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.

@blowekamp blowekamp requested a review from zivy January 24, 2020 22:20
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.
@blowekamp blowekamp force-pushed the RefactorRelabelComponentImageFilter branch from 6392779 to 234bbf3 Compare January 25, 2020 02:20
Copy link
Member

@zivy zivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work. Speedups always welcome.

@blowekamp blowekamp merged commit 8ed7711 into InsightSoftwareConsortium:master Jan 27, 2020
hjmjohnson added a commit that referenced this pull request Sep 21, 2025
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants