[Insight-developers] The Cost of Having something Pretty... 11 MB

Bradley Lowekamp blowekamp at mail.nih.gov
Mon Mar 5 09:23:04 EST 2012


Hello all,

I have been idly trying to make the SimpelITK libraries smaller. I noticed over 35K of __PRETTY_FUNCTION__ string symbols in the simpleITK Python library, when build with the static sitk and itk libraries. The pretty function, is primarily used for the itkExceptoinMacros defined in itkMacro.h. I deleted that usage, and rebuilt. Now, there are only 5.7K of pretty symbols. The size of the library went down 11 megabytes, which is 9.5% of the total library size.

So our exceptions are entirely too verbose and there needs to be an option to reduce the amount of bloat they cause. As the macro already specifies the file name and line number where the exception occurred, I think the pretty location, is redundant, and quickly can cause bloat, so is should not be used in release mode by default.

I an reluctant to propose another top-level CMake variable for this, but  I think this option needs to go into the itkConfigure.h file, as having a command line define may be too problematic. 

Anyone have any thoughts on this topic?

I also would like to bring up that I am starting to use the "-fvisibility-inlines-hidden" and "-fvisibility=hidden". Initial results on SimpelITK reduced the library size by 20MB or 14%. The inline argument is harmless and appears to have no downside, and likely should be added as a default flag to just about all applications which use ITK. Changing the default visibility to hidden, is full of complications, and requires a large number of changes to the ITK libraries, mostly shouldn't be too hard.

I also believe that Wrap ITK should be able to significantly benefit from these observations, and likely reduce the size of the library by 20% with these improvements.

Brad

========================================================
Bradley Lowekamp  
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20120305/1a302d7e/attachment.htm>


More information about the Insight-developers mailing list