While improved explicit instantiation support would help the build time and binary size of Python bindings and other large applications, we should not be striving, in general, for forced, explicit instantiation.
An optional explicit instantiation, as described here:
would be a nice feature.
More explicit instantiation increases build complexity, build times, and build size for common use cases. If an application is developed using templates, only the template instantiations that are used are compiled. You not need to compile and link instantiations that are not used.
In my ITK build, libITKTransformFactory-5.0.so.1
followed by libitkvnl-5.0.so.1
are the largest libraries with a whopping 5.8 MB and 4.7 MB, respectively, even for an -Os
/ MinSizeRel
build. In a real application, are both float
and double
transform’s of all different types for dimension 1-9 used? Rarely if ever.
In particular, it is extremely important that we do not build and link unused code when generating WebAssembly binaries. This impacts binary size, which is critical for WebAssembly. The ITKCommon
and itkvnl
libraries need to go on a diet for this use case.
An approach of fixed size implementations for common sizes and dynamic implementations for larger sizes provides a good balance of performance and binary size. Fixed sizes that are always used could be explicitly instantiated.
Build errors related to vnl_matrix_fixed
are also reported for ANTs here: