[Insight-developers] Empty FixedArray destructor: Performance hit using gcc (times 2)
Tom Vercauteren
tom.vercauteren at gmail.com
Thu Jun 5 04:15:37 EDT 2008
Hi all,
After some code profiling, we stumbled on a mysterious performance hit
related to the empty destructor used in itk::FixedArray. The
explanation of it is not really clear yet but the fix is easy: Do not
implement the destructor. I'll be happy to commit the change if nobody
is against it.
Here is the setting. We create an image of the following type:
itk::Image< itk::Vector< double, 2 >, 2 > image;
On the platforms we use (gcc 4.1 for linux or gcc 4.0 for mac), we realized that
image->GetBufferPointer()
was aligned on 4 bytes
Now by removing the empty implementation of ~FixedArray() we saw that
image->GetBufferPointer()
was now aligned on 8 bytes
In the (home-made) filter we use, the execution time with the current
implementation is twice as long as the one with an empty FixedArray
destructor.
Note that since ~FixedArray() is empty and not virtual, removing its
implementation should not lead to any backward compatibility issue.
Let me know if you need further information, if you have a good
explanation for this behavior or if you know a better solution.
Best,
Tom Vercauteren
More information about the Insight-developers
mailing list