Page MenuHomePhabricator

Sort faster during DICOM loading
Closed, ResolvedPublic

Description

The spatial sorting function in DicomSeriesReader constructs many, many Tag objects during sorting. Since these objects are constant, they could as well be declared "static" in order to create them only once.

This change gains a bit more performance.

Event Timeline

maleike added a subscriber: maleike.

New remote branch pushed: bug-15700-dicom-sort-faster

[7cb82d]: Merge branch 'bug-15700-dicom-sort-faster'

Merged commits:

2013-07-23 09:25:04 Daniel Maleike [90e85e]
Declare most of the sorting function variables static

Seems that construction of these variables takes some time
with bigger series. Taking construction out of the loop should
speed up things.

REVIEW:

Simple fix to speedup sorting of DICOM files. By declaring Tag objects as static, they do not need to be constructed in each run.

New remote branch pushed: bug-15700-dicom-sort-faster-rebased

[6537f1]: Merge branch 'bug-15700-dicom-sort-faster'

Merged commits:

2013-07-26 11:46:47 Daniel Maleike [17ad52]
Revert most of the "static Attribute" mistake

When using static variables, one should always think about threaded
use cases..

(In reply to Markus Engel from comment #3)

By declaring Tag objects as
static, they do not need to be constructed in each run.

Yes, BUT.. as I should have seen, static variables will be used accross threads, so loading two DICOM series at the same time can (and will) mess up slice sorting, when both threads modify the variables at the same time.

I just reverted the non-const static declarations. The tags can still be static, they are declared const and are never changed.