qmldom: add Minimal DomCreationOption for QDS
DOM construction time is quite slow for the QDS use case, so add a new minimal DomCreationOptions that ignores comments (as QDS has no need for comments) because comments seem to take some time to construct. Add the Minimal DomCreationOptions to the Benchmark to show that it is faster then using the Default DomCreationOptions. Measured on my machine, using a release build: File | Default (ms) | Minimal (ms) | Speedup tiger.qml | 83 | 38 | 2.18 deeplyNested.qml | 438 | 12 | 36.5 The 36.5 speedup does look weird at first, but a quick look in the profiler shows that we spend 95% of the benchmark time for deeplyNested.qml with Default DomCreationOptions in * Path::component() and * DomItem::field() while trying to iterate on the Qml Document to find the comments. So its not a bug, its just the linear complexity of Path::component() and DomItem::field() that proves to be inadequate in our case: * Path::component(i) returns the i.th path component, and needs to iterate through all components to find it * DomItem::field(f) returns the value of the field f, and uses iterateDirectSubpaths() which is linear in the number of total fields, and it seems the laziness there might not be working as expected. Pick-to: 6.8 6.9 Task-number: QTBUG-92889 Change-Id: I51168b68e930ed14d1751cf0f6028b1b2879b774 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
This commit is contained in:
parent
f3ed490f87
commit
381c5e7ed5
|
@ -414,6 +414,7 @@ Q_ENUM_NS(FileLocationRegion);
|
|||
enum DomCreationOption : char {
|
||||
Default, // required by qmlformat for example
|
||||
Extended, // required by qmlls for example
|
||||
Minimal, // required by QmlDocumentParser in Qt Design Studio, for example
|
||||
};
|
||||
|
||||
} // end namespace Dom
|
||||
|
|
|
@ -2241,6 +2241,10 @@ void DomEnvironment::populateFromQmlFile(MutableDomItem &&qmlFile)
|
|||
Q_UNUSED(this); // note: integrity requires "this" to be in the capture list, while
|
||||
// other compilers complain about "this" being unused in the lambda
|
||||
AST::Node::accept(qmlFilePtr->ast(), visitor);
|
||||
|
||||
if (m_domCreationOption == DomCreationOption::Minimal)
|
||||
return;
|
||||
|
||||
CommentCollector collector(qmlFile);
|
||||
collector.collectComments();
|
||||
};
|
||||
|
|
|
@ -32,6 +32,9 @@ void tst_qmldomconstruction::domConstructionTime_data()
|
|||
|
||||
QTest::addRow("extended-tiger.qml") << baseDir + u"/longQmlFile.qml"_s << Extended;
|
||||
QTest::addRow("extended-deeplyNested.qml") << baseDir + u"/deeplyNested.qml"_s << Extended;
|
||||
|
||||
QTest::addRow("minimal-tiger.qml") << baseDir + u"/longQmlFile.qml"_s << Minimal;
|
||||
QTest::addRow("minimal-deeplyNested.qml") << baseDir + u"/deeplyNested.qml"_s << Minimal;
|
||||
}
|
||||
|
||||
void tst_qmldomconstruction::domConstructionTime()
|
||||
|
|
Loading…
Reference in New Issue