Skip to content

Improve startup time

Sam Horvath requested to merge github/fork/jcfr/improve-startup-time into master

Created by: jcfr

PERF: Improve startup time delaying execution of shared and executable CLIs

This commit reduces startup time by ~50% (8.6s -> 5.5s). Detailed startup time stats reported below.

More specifically, it updates the loadable and executable CLI factories so that (1) the XML file is directly loaded from disk if it exists along side the executable or library and (2) the execution of the executable or "entry point" for shared library is delayed until needed.

For CLI executable, change consists simply in reading the XML file if it exists and postpone the execution until it is needed.

For CLI shared library, the ModuleDescription object API has been updated. It now allows the association of a callback in charge of loading the library and resolving symbols. The callback is automatically called when "GetTarget()" method is called and no target has already been set.

Note that the XML file is now copied (and installed if it applies) along side the CLI executable. There are currently no option to avoid the new behavior, if it reveals problematic, we could revisit and introduce an option for "SEMMacroBuildCLI" macro.

Detailed startup time stats without this change are reported in precedent commit (ENH: Add convenience script to measure the application startup time).

Detailed startup time stats after this change:

  • Obtained on Ubuntu 15.10, 64GB/M.2 PCIe NVMe SSD/Quad Core 3.80GHz.
  • For a release build
Slicer --no-splash --exit-after-startup
5.537 seconds

Slicer --no-splash --exit-after-startup --disable-builtin-cli-modules
5.438 seconds

Slicer --no-splash --exit-after-startup --disable-builtin-loadable-modules
2.863 seconds

Slicer --no-splash --exit-after-startup --disable-builtin-scripted-loadable-modules
3.925 seconds

Slicer --no-splash --exit-after-startup --disable-builtin-cli-modules --disable-builtin-scripted-loadable-modules
3.973 seconds

Slicer --no-splash --exit-after-startup --disable-modules
1.761 seconds

Slicer --no-splash --exit-after-startup --disable-python
3.094 seconds

Slicer --no-splash --exit-after-startup --disable-python --disable-builtin-cli-modules
3.054 seconds

Slicer --no-splash --exit-after-startup --disable-python --disable-builtin-loadable-modules
0.972 seconds

Slicer --no-splash --exit-after-startup --disable-python --disable-builtin-scripted-loadable-modules
3.135 seconds

Slicer --no-splash --exit-after-startup --disable-python --disable-builtin-cli-modules --disable-builtin-scripted-loadable-modules
3.085 seconds

Slicer --no-splash --exit-after-startup --disable-python --disable-modules
0.924 seconds

SlicerExecutionModel changes:

$ git shortlog b2c78c7..1b2a454 --no-merges
Jean-Christophe Fillion-Robin (9):
      STYLE: ModuleDescription: Move definition to cxx file
      STYLE: Remove obsolete ModuleFactory class
      STYLE: ModuleDescription: Remove unused Alternative Type/Target/Location
      STYLE: Remove obsolete BinaryFileDescriptor support
      STYLE: ModuleDescriptionParser: Add separator comment, small tweaks
      STYLE: Add ModuleDescriptionTesting Macros and Utilities files
      STYLE: ModuleDescription: Add TestDefaults
      ENH: ModuleDescription: Add support for lazily setting the target
      ENH: Update SEMMacroBuildCLI to copy (and optionally install) the XML file

Merge request reports

Loading