[PREVIEW-WIP] PERF: Improve startup time by 8% with lazy loading of wrapped libraries #509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
*** WORK IN PROGRESS: For now, you have to make sure SlicerApp-real and
Slicer launcher are built to ensure the successful generation of the json
files ***
Startup time reduced from 3.8s to 3.5s with a "cold cache"
and from 2.7s to 2.38s with a "warm cache".
For each logic/mrml/dm/widgets python modules, a json files listing
the associated attributes is generated. Then, when the application is
initialized, the "slicer" module is created as a "lazy" module with
the attributes associated with logic/mrml/dm/widgets set as "not loaded".
Finally, as soon as an attribute not yet loaded is accessed, the specialized
__getattribute__
loads the associated python module and update the moduledictionary.
The "lazy" module has been adapted from "itkLazy.py"
Results have been gathered on Ubuntu 15.10 on a workstation with the
following specs: 64GB / M.2 PCIe NVMe SSD / Quad Core 3.80GHz