Skip to content
Permalink
Browse files

PERF: Reduce startup time by lazily loading Welcome module HTML. Fixe…

…s #4198

This commit reduces startup time by ~30% (5.5s -> 3.9s).

Results obtained for a release build on Ubuntu 15.10, 64GB/M.2 PCIe
NVMe SSD/Quad Core 3.80GHz.

While loading the Welcome module is still  slower (~10ms), the improvement
is significant.


Details Stats:


Notes: MeasureStartupTimes.py has been locally modified to avoid generating
Modules.json. Modules.json has been updated to list only 4 modules.


$ ~/Projects/Slicer/Applications/SlicerApp/Testing/Python/MeasureStartupTimes.py --excluding-one-module -n5 ./Slicer

[1/4]
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore EventBroker
1/5: 3.81s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore EventBroker
2/5: 3.81s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore EventBroker
3/5: 3.79s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore EventBroker
4/5: 3.82s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore EventBroker
5/5: 3.84s
Average: 3.81s

[2/4]
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore GradientAnisotropicDiffusion
1/5: 3.84s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore GradientAnisotropicDiffusion
2/5: 3.83s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore GradientAnisotropicDiffusion
3/5: 3.83s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore GradientAnisotropicDiffusion
4/5: 3.75s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore GradientAnisotropicDiffusion
5/5: 3.85s
Average: 3.82s

[3/4]
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore Welcome
1/5: 3.70s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore Welcome
2/5: 3.75s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore Welcome
3/5: 3.73s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore Welcome
4/5: 3.76s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore Welcome
5/5: 3.68s
Average: 3.72s

[4/4]
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore CompareVolumes
1/5: 3.78s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore CompareVolumes
2/5: 3.78s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore CompareVolumes
3/5: 3.80s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore CompareVolumes
4/5: 3.82s
Slicer --no-splash --exit-after-startup --testing --modules-to-ignore CompareVolumes
5/5: 3.76s
Average: 3.79s

git-svn-id: http://svn.slicer.org/Slicer4/trunk@25104 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information...
jcfr committed May 21, 2016
1 parent e4c4949 commit 9cf170a4cdd8c27f3acc0a76b313c1eae1c8f6ed
@@ -164,7 +164,7 @@
<string>Feedback</string>
</property>
<property name="collapsed">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="contentsFrameShape">
<enum>QFrame::StyledPanel</enum>
@@ -187,11 +187,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/Feedback.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -229,11 +224,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/About.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -271,11 +261,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/Overview.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -313,11 +298,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/LoadingScenesAndData.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -355,11 +335,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/AdjustingDataDisplay.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -397,11 +372,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/MouseModes.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -439,11 +409,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/OtherUsefulHints.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -481,11 +446,6 @@
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="source">
<url>
<string>qrc:HTML/Acknowledgment.html</string>
</url>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -23,6 +23,7 @@
#include <QMainWindow>
#include <QMessageBox>
#include <QSettings>
#include <QSignalMapper>

// Slicer includes
#include "vtkSlicerConfigure.h" // For Slicer_BUILD_DICOM_SUPPORT
@@ -56,6 +57,8 @@ class qSlicerWelcomeModuleWidgetPrivate: public Ui_qSlicerWelcomeModuleWidget
void setupUi(qSlicerWidget* widget);

bool selectModule(const QString& moduleName);

QSignalMapper CollapsibleButtonMapper;
};

//-----------------------------------------------------------------------------
@@ -70,6 +73,8 @@ qSlicerWelcomeModuleWidgetPrivate::qSlicerWelcomeModuleWidgetPrivate(qSlicerWelc
//-----------------------------------------------------------------------------
void qSlicerWelcomeModuleWidgetPrivate::setupUi(qSlicerWidget* widget)
{
Q_Q(qSlicerWelcomeModuleWidget);

this->Ui_qSlicerWelcomeModuleWidget::setupUi(widget);

// Create the button group ensuring that only one collabsibleWidgetButton will be open at a time
@@ -84,6 +89,50 @@ void qSlicerWelcomeModuleWidgetPrivate::setupUi(qSlicerWidget* widget)

QObject::connect(this->OpenExtensionsManagerButton, SIGNAL(clicked()),
qSlicerApplication::application(), SLOT(openExtensionsManagerDialog()));


// Lazily set the fitted browser source to avoid overhead when the module
// is loaded.
this->FeedbackCollapsibleWidget->setProperty("source", "qrc:HTML/Feedback.html");
this->WelcomeAndAboutCollapsibleWidget->setProperty("source", "qrc:HTML/About.html");
this->OverviewCollapsibleWidget->setProperty("source", "qrc:HTML/Overview.html");
this->LoadingScenesAndDataCollapsibleWidget->setProperty("source", "qrc:HTML/LoadingScenesAndData.html");
this->AdjustingDataDisplayCollapsibleWidget->setProperty("source", "qrc:HTML/AdjustingDataDisplay.html");
this->MouseModesCollapsibleWidget->setProperty("source", "qrc:HTML/MouseModes.html");
this->OtherUsefulHintsCollapsibleWidget->setProperty("source", "qrc:HTML/OtherUsefulHints.html");
this->AcknowledgmentCollapsibleWidget->setProperty("source", "qrc:HTML/Acknowledgment.html");

foreach(QWidget* widget, QWidgetList()
<< this->FeedbackCollapsibleWidget
<< this->WelcomeAndAboutCollapsibleWidget
<< this->OverviewCollapsibleWidget
<< this->LoadingScenesAndDataCollapsibleWidget
<< this->AdjustingDataDisplayCollapsibleWidget
<< this->MouseModesCollapsibleWidget
<< this->OtherUsefulHintsCollapsibleWidget
<< this->AcknowledgmentCollapsibleWidget
)
{
this->CollapsibleButtonMapper.setMapping(widget, widget);
QObject::connect(widget, SIGNAL(contentsCollapsed(bool)),
&this->CollapsibleButtonMapper, SLOT(map()));
}

QObject::connect(&this->CollapsibleButtonMapper, SIGNAL(mapped(QWidget*)),
q, SLOT(loadSource(QWidget*)));
}

//-----------------------------------------------------------------------------
void qSlicerWelcomeModuleWidget::loadSource(QWidget* widget)
{
// Lookup fitted browser
ctkFittedTextBrowser* fittedTextBrowser =
widget->findChild<ctkFittedTextBrowser*>();
Q_ASSERT(fittedTextBrowser);
if (fittedTextBrowser->source().isEmpty())
{
fittedTextBrowser->setSource(widget->property("source").toString());
}
}

//-----------------------------------------------------------------------------
@@ -148,6 +197,8 @@ void qSlicerWelcomeModuleWidget::setup()
#endif

this->Superclass::setup();

d->FeedbackCollapsibleWidget->setCollapsed(false);
}


@@ -54,6 +54,9 @@ public slots:
protected:
virtual void setup();

protected slots:
void loadSource(QWidget*);

protected:
QScopedPointer<qSlicerWelcomeModuleWidgetPrivate> d_ptr;

0 comments on commit 9cf170a

Please sign in to comment.
You can’t perform that action at this time.