aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2016-12-22 13:40:19 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2016-12-22 17:10:47 +0000
commit5a8d76c2f6006ff70bcc78853dbe95b6465851a8 (patch)
tree1f57894437450c7b81682e49d028f0b6f81da597
parent519d065e008e75589f6ce440d840f4114c22b275 (diff)
Do not remove artifacts from the scan result cache
Presumably, this code was to ensure that only finished artifacts would be retrieved from the cache. However, we can simply make sure that sure unbuilt artifacts do not end up there in the first place. Benchmarker output is below. Real-world numbers: When building the Qt Creator super project, the total number of scanned header files goes down from 24966 to 17889. ========== Performance data for Rule Execution ========== Old instruction count: 3560941434 New instruction count: 3399056106 Relative change: -5 % Old peak memory usage: 17590920 Bytes New peak memory usage: 17668328 Bytes Relative change: +0 % Task-number: QBS-1052 Change-Id: Ic76f9d5f2e74fa694d5584ad3f4f2edf5d5b136d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/lib/corelib/buildgraph/executor.cpp1
-rw-r--r--src/lib/corelib/buildgraph/inputartifactscanner.cpp7
-rw-r--r--src/lib/corelib/buildgraph/scanresultcache.cpp9
-rw-r--r--src/lib/corelib/buildgraph/scanresultcache.h1
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp2
5 files changed, 4 insertions, 16 deletions
diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp
index d5e45f85b..a763e83bf 100644
--- a/src/lib/corelib/buildgraph/executor.cpp
+++ b/src/lib/corelib/buildgraph/executor.cpp
@@ -646,7 +646,6 @@ void Executor::finishArtifact(Artifact *leaf)
m_logger.qbsTrace() << "[EXEC] finishArtifact " << relativeArtifactFileName(leaf);
finishNode(leaf);
- m_scanResultCache.remove(leaf->filePath());
}
QString Executor::configString() const
diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp
index cdf38b247..a505d3b21 100644
--- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp
+++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp
@@ -290,10 +290,11 @@ resolved:
handleDependency(resolvedDependency);
if (artifactsToScan && resolvedDependency.file) {
if (Artifact *artifactDependency = dynamic_cast<Artifact *>(resolvedDependency.file)) {
- // Do not scan artifacts that are being built. Otherwise we might read an incomplete
- // file or conflict with the writing process.
- if (artifactDependency->buildState != BuildGraphNode::Building)
+ // Do not scan an artifact that is not built yet: Its contents might still change.
+ if (artifactDependency->artifactType == Artifact::SourceFile
+ || artifactDependency->buildState == BuildGraphNode::Built) {
artifactsToScan->append(artifactDependency);
+ }
} else {
// Add file dependency to the next round of scanning.
artifactsToScan->append(resolvedDependency.file);
diff --git a/src/lib/corelib/buildgraph/scanresultcache.cpp b/src/lib/corelib/buildgraph/scanresultcache.cpp
index 93986264a..9e1b3ccf8 100644
--- a/src/lib/corelib/buildgraph/scanresultcache.cpp
+++ b/src/lib/corelib/buildgraph/scanresultcache.cpp
@@ -61,14 +61,5 @@ void ScanResultCache::insert(const void *scanner, const QString &fileName, const
m_data[scanner].insert(fileName, value);
}
-void ScanResultCache::remove(const QString &fileName)
-{
- ScanResultCacheData::iterator i = m_data.begin();
- while (i != m_data.end()) {
- i.value().remove(fileName);
- ++i;
- }
-}
-
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/buildgraph/scanresultcache.h b/src/lib/corelib/buildgraph/scanresultcache.h
index a5c670c71..f01431047 100644
--- a/src/lib/corelib/buildgraph/scanresultcache.h
+++ b/src/lib/corelib/buildgraph/scanresultcache.h
@@ -83,7 +83,6 @@ public:
Result value(const void* scanner, const QString &fileName) const;
void insert(const void* scanner, const QString &fileName, const Result &value);
- void remove(const QString &fileName);
private:
typedef QHash<const void*, QHash<QString, Result> > ScanResultCacheData;
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 051232788..38dc22b40 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -328,7 +328,6 @@ void TestBlackbox::artifactScanning()
QCOMPARE(m_qbsStderr.count("scanning p1.cpp"), 1);
QCOMPARE(m_qbsStderr.count("scanning p2.cpp"), 1);
QCOMPARE(m_qbsStderr.count("scanning p3.cpp"), 1);
- QEXPECT_FAIL(0, "QBS-1052", Continue);
QCOMPARE(m_qbsStderr.count("scanning shared.h"), 1);
QCOMPARE(m_qbsStderr.count("scanning external.h"), 1);
QCOMPARE(m_qbsStderr.count("scanning external2.h"), 1);
@@ -382,7 +381,6 @@ void TestBlackbox::artifactScanning()
QEXPECT_FAIL(0, "QBS-1052", Continue);
QCOMPARE(m_qbsStderr.count("scanning p2.cpp"), 0);
QCOMPARE(m_qbsStderr.count("scanning p3.cpp"), 0);
- QEXPECT_FAIL(0, "QBS-1052", Continue);
QCOMPARE(m_qbsStderr.count("scanning shared.h"), 1);
QEXPECT_FAIL(0, "QBS-1052", Continue);
QCOMPARE(m_qbsStderr.count("scanning external.h"), 0);