How to Optimize Slicer Extension Load Time for Large Custom Toolsets

Hello

I am developing a custom Slicer extension that bundles many specialized tools & modules for a specific medical imaging workflow.:slightly_smiling_face: While the extension works well once loaded; the startup time of Slicer has increased noticeably especially on systems with slower disks / limited RAM. :upside_down_face:

I am looking for ways to reduce this load time without removing key features from the extension.

I have considered breaking the extension into smaller, on-demand modules but I am not sure of the best way to structure that within the Slicer extension framework.:thinking: Another idea is to lazy-load certain resources (icons, data files, Python scripts) only when a module is opened for the first time.

If anyone has tried similar optimizations, tips or example repositories would be great. A good starting point for those interested in this topic might be the Slicer Developer Guide on Extensions, but I am looking for more practical, performance-focused advice based on real-world use cases.:innocent: While working on these optimizations; I found what is java often linked with discussions about startup speed.

I’d like to hear from others who have worked on large extensions what patterns / optimizations helped you keep Slicer startup fast?:thinking:

Thank you !!

One option could be making a custom app from your extension where you can specify all the modules you don’t need in the main CMakeLists file.

I suppose lazy loading could be an option, but in that case (if you use Slicer and not custom app) the problem would be that the module list wouldn’t contain the not-yet-loaded module and thus the user wouldn’t be able to choose it. You’d need to add a button in your module to load and switch to that module.